Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

hondahead95

macrumors newbie
Original poster
Apr 16, 2009
7
0
The U S of A
I was trying to write up an app when I got a syntax error. I'm new to this (as in I've never written much code) and could use some help. :[
Code:
//
// Prefix header for all source files of the 'Pixel Car App' target in the 'Pixel Car App' project
//

#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#endif
//RootViewController.m;
@implementation[applicationDidFinishLaunching int] (UIApplication *)application 
@end
{
	pvController = [PickerViewController alloc] initWithNibName:@"Car Select" bundle:[NSBundle mainBundle]];
	
	[window addSubview:pvController.view];
	
	// Override point for customization after application launch
	[window makeKeyAndVisible];
}
//Pixel_Car_AppAppDelegate.m



	
[arrayCars int][initWithNibName];
	
	[arrayCars addObject:@"Nissan Skyline"];
	[arrayCars addObject:@"Nissan 350Z"];
	[arrayCars addObject:@"Volkswagen GTi"];
	[arrayCars addObject:@"Green"];
	[arrayCars addObject:@"Blue"];
	[arrayCars addObject:@"Indigo"];
	[arrayCars addObject:@"Violet"];
}
Could someone who knows what they're doing please help me?
 

JLatte

macrumors 6502
Dec 2, 2005
336
0
San Diego
Well, I'm not entirely sure where you're getting the error. I believe I see at least a few things wrong though:

I'm assuming RootViewController.m is the name of your file. The @implentation should be reading @implementation RootViewController

Also, your @implementation is followed immediately by @end with no implementation defined.

Let me just start at the very beginning actually...

You can get rid of the #ifdef and #endif statements.

applicationDidFinishLaunching is its own method and should be placed appropriately. Since you're overriding it, you're going to need -(void)applicationDidFinishLaunching { code goes here }

I see quite a few errors actually, I'd recommend reading up a bit more on Obj-C. Check Apple's documentation site.
 

hondahead95

macrumors newbie
Original poster
Apr 16, 2009
7
0
The U S of A
Code:
//
// Prefix header for all source files of the 'Pixel Car App' target in the 'Pixel Car App' project
//

#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#endif
@implentation RootViewController

(void)applicationDidFinishLaunching int] (UIApplication *)application 
@end
{
	pvController = [PickerViewController alloc] initWithNibName:@"Car Select" bundle:[NSBundle mainBundle]];
	
	[window addSubview:pvController.view];
	
	// Override point for customization after application launch
	[window makeKeyAndVisible];
}
//Pixel_Car_AppAppDelegate.m



	
[arrayCars int][initWithNibName];
	
	[arrayCars addObject:@"Nissan Skyline"];
	[arrayCars addObject:@"Nissan 350Z"];
	[arrayCars addObject:@"Volkswagen GTi"];
	[arrayCars addObject:@"Green"];
	[arrayCars addObject:@"Blue"];
	[arrayCars addObject:@"Indigo"];
	[arrayCars addObject:@"Violet"];
}
Now it says: Syntax Error before "Void"
 

JLatte

macrumors 6502
Dec 2, 2005
336
0
San Diego
change this:

Code:
(void)applicationDidFinishLaunching int] (UIApplication *)application 
@end
{
	pvController = [PickerViewController alloc] initWithNibName:@"Car Select" bundle:[NSBundle mainBundle]];
	
	[window addSubview:pvController.view];
	
	// Override point for customization after application launch
	[window makeKeyAndVisible];
}


to

Code:
@implentation RootViewController

-(void)applicationDidFinishLaunching:(UIApplication *)application 
{
	pvController = [PickerViewController alloc] initWithNibName:@"Car Select" bundle:[NSBundle mainBundle]];
	
	[window addSubview:pvController.view];
	
	// Override point for customization after application launch
	[window makeKeyAndVisible];
}
@end

Also, I see you using pvController, however I don't see you declaring it, or synthesizing it. Do you need @synthesizers?

One other thing, it looks like your rootviewcontroller should be the latter part and not the first part. The first part looks like it should be your appDelegate.
 

hondahead95

macrumors newbie
Original poster
Apr 16, 2009
7
0
The U S of A
Now it's giving me this:
Line Location Tool:0: CodeSign error: Code Signing Identity 'iPhone Developer' does not match any code-signing certificate in your keychain. Once added to the keychain, touch a file or clean the project to continue.
 

JLatte

macrumors 6502
Dec 2, 2005
336
0
San Diego
Now it's giving me this:
Line Location Tool:0: CodeSign error: Code Signing Identity 'iPhone Developer' does not match any code-signing certificate in your keychain. Once added to the keychain, touch a file or clean the project to continue.

heh... Are you trying to load it to an iPhone or are you using the simulator?
 

JLatte

macrumors 6502
Dec 2, 2005
336
0
San Diego
To my iTouch. I guess I should do the simulator first.

Do the simulator. Are you a registered developer, meaning you paid the $99? That's the only way you can test it on an actual physical device. If you didn't pay the $99, you can still use the simulator and it'll be just fine.
 

hondahead95

macrumors newbie
Original poster
Apr 16, 2009
7
0
The U S of A
Do the simulator. Are you a registered developer, meaning you paid the $99? That's the only way you can test it on an actual physical device. If you didn't pay the $99, you can still use the simulator and it'll be just fine.
Oh, well then, that's why! Haha. But now it's giving me another syntax error in front of the '@' token.
Code:
//
// Prefix header for all source files of the 'Pixel Car App' target in the 'Pixel Car App' project
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@implentation RootViewController

-(void)applicationDidFinishLaunching:(UIApplication *)application 
{
	pvController = [PickerViewController alloc] initWithNibName:@"Car Select" bundle:[NSBundle mainBundle]];
	
	[window addSubview:pvController.view]
@end
//Pixel_Car_AppAppDelegate.m



	
[arrayCars int][initWithNibName];
	
	[arrayCars addObject:@"Nissan Skyline"];
	[arrayCars addObject:@"Nissan 350Z"];
	[arrayCars addObject:@"Volkswagen GTi"];
	[arrayCars addObject:@"Volkswagen Polo"];
	[arrayCars addObject:@"Honda Civic Hatch"];
	[arrayCars addObject:@"Indigo"];
	[arrayCars addObject:@"Violet"];
}
 

JLatte

macrumors 6502
Dec 2, 2005
336
0
San Diego
Ok, well several things:

You need an @interface file to go with that @implementation. Seeing as it seems you've done it all in one file, I'm not seeing an @interface. This won't fix it, and I can't tell without seeing the entire file, however you should move that @end to the very bottom of all of your code.
 

hondahead95

macrumors newbie
Original poster
Apr 16, 2009
7
0
The U S of A
I fixed the typo.
Still have problems
Line Location Pixel_Car_App_Prefix.pch:8: warning: cannot find interface declaration for 'RootViewController'
Line Location Pixel_Car_App_Prefix.pch:10: error: syntax error before 'initWithNibName'
Line Location Pixel_Car_App_Prefix.pch:10: error: 'PickerViewController' undeclared (first use in this function)
Line Location Pixel_Car_App_Prefix.pch:10: error: 'pvController' undeclared (first use in this function)
Line Location Pixel_Car_App_Prefix.pch:12: error: 'window' undeclared (first use in this function)
Line Location Pixel_Car_App_Prefix.pch:18: error: syntax error before 'int'
Line Location Pixel_Car_App_Prefix.pch:18: error: 'arrayCars' undeclared (first use in this function)
Line Location Pixel_Car_App_Prefix.pch:27: error: syntax error before 'AT_NAME' token
Code:
//
// Prefix header for all source files of the 'Pixel Car App' target in the 'Pixel Car App' project
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@implementation RootViewController

-(void)applicationDidFinishLaunching:(UIApplication *)application 
{
	pvController = [PickerViewController alloc] initWithNibName:@"Car Select" bundle:[NSBundle mainBundle]];
	
	[window addSubview:pvController.view]
//Pixel_Car_AppAppDelegate.m



	
[arrayCars int][initWithNibName];
	
	[arrayCars addObject:@"Nissan Skyline"];
	[arrayCars addObject:@"Nissan 350Z"];
	[arrayCars addObject:@"Volkswagen GTi"];
	[arrayCars addObject:@"Volkswagen Polo"];
	[arrayCars addObject:@"Honda Civic Hatch"];
	[arrayCars addObject:@"Indigo"];
	[arrayCars addObject:@"Violet"];
@end
 

JLatte

macrumors 6502
Dec 2, 2005
336
0
San Diego
I fixed the typo.
Still have problems
Line Location Pixel_Car_App_Prefix.pch:8: warning: cannot find interface declaration for 'RootViewController'
Line Location Pixel_Car_App_Prefix.pch:10: error: syntax error before 'initWithNibName'
Line Location Pixel_Car_App_Prefix.pch:10: error: 'PickerViewController' undeclared (first use in this function)
Line Location Pixel_Car_App_Prefix.pch:10: error: 'pvController' undeclared (first use in this function)
Line Location Pixel_Car_App_Prefix.pch:12: error: 'window' undeclared (first use in this function)
Line Location Pixel_Car_App_Prefix.pch:18: error: syntax error before 'int'
Line Location Pixel_Car_App_Prefix.pch:18: error: 'arrayCars' undeclared (first use in this function)
Line Location Pixel_Car_App_Prefix.pch:27: error: syntax error before 'AT_NAME' token

That first warning is because like I mentioned earlier, you need an @interface if you have an @implementation. Seeing as you didn't import a header file, and it looks like you're writing it all in one single file, you still need to have an @interface and any accessors within it. Then you'll need @synthesizers, and then the rest of your code. If that's done correctly, the rest should fix itself. I highly recommend checking out the apple documentation on objective C coding at this point.
 

mccannmarc

macrumors 6502
Aug 15, 2008
270
0
Manchester, UK
It looks like you have added that class implementation to your apps prefix.pch

You can't implement a class in there! You really ought to learn how to program and/or manage your workspace before jumping into a project
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
(Seems like I'm saying this almost weekly lately.) It's time to step back from this code and go learn the basics before doing any more real coding.
 

firewood

macrumors G3
Jul 29, 2003
8,141
1,384
Silicon Valley
Could someone who knows what they're doing please help me?

Apple has plenty of examples on their developer site. Read their code. Then read the documentation to figure out why every line is where it is. Then you will know why putting those lines in different places won't work.

eek
 

BlackWolf

macrumors regular
Apr 9, 2009
244
0
(Seems like I'm saying this almost weekly lately.) It's time to step back from this code and go learn the basics before doing any more real coding.

signed 100%.
you don't know the most basic syntax of objective-c (I mean really, BASIC). before you learned that, doing a project is a no-go. please, please read up about the syntax. how a class is declared, how a method is declared, how you send a message to an object, how you assign variables, etc. etc.
also read up how an xcode project looks, what files are in there and what they do.

otherwise we can give you tons and tons of fixes, it's never gonna stop. this is like if you don't speak french but you're trying to write a french book only with the help of a vocabulary book - this is leading nowhere.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.