PDA

View Full Version : iPhone App issues




hondahead95
Apr 16, 2009, 05:06 PM
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. :[

//
// 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
Apr 16, 2009, 05:20 PM
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.

dejo
Apr 16, 2009, 05:22 PM
What's the exact syntax error?

hondahead95
Apr 16, 2009, 05:32 PM
//
// 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
Apr 16, 2009, 05:40 PM
change this:

(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

@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
Apr 16, 2009, 05:46 PM
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
Apr 16, 2009, 05:49 PM
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?

hondahead95
Apr 16, 2009, 05:52 PM
To my iTouch. I guess I should do the simulator first.

JLatte
Apr 16, 2009, 05:53 PM
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
Apr 16, 2009, 06:01 PM
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.

//
// 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
Apr 16, 2009, 06:03 PM
Oh, well then, that's why! Haha. But now it's giving me another syntax error in front of the '@' token.


Going to need to see the entire syntax error.

hondahead95
Apr 16, 2009, 06:04 PM
Line Location Pixel_Car_App_Prefix.pch:6: error: syntax error before '@' token

JLatte
Apr 16, 2009, 06:08 PM
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.

mccannmarc
Apr 16, 2009, 06:15 PM
Another thing which stands out like a sore thumb:-

what the hell is @implentation? I think you mean to put @implementation

hondahead95
Apr 16, 2009, 06:22 PM
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

//
// 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
Apr 16, 2009, 06:25 PM
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
Apr 16, 2009, 06:28 PM
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
Apr 16, 2009, 06:45 PM
(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
Apr 16, 2009, 10:56 PM
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
Apr 17, 2009, 09:47 AM
(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.