iPhone App issues

Discussion in 'iPhone/iPad Programming' started by hondahead95, Apr 16, 2009.

  1. macrumors newbie

    Joined:
    Apr 16, 2009
    Location:
    The U S of A
    #1
    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?
     
  2. macrumors 6502

    Joined:
    Dec 2, 2005
    Location:
    San Diego
    #2
    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.
     
  3. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #3
    What's the exact syntax error?
     
  4. thread starter macrumors newbie

    Joined:
    Apr 16, 2009
    Location:
    The U S of A
    #4
    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"
     
  5. macrumors 6502

    Joined:
    Dec 2, 2005
    Location:
    San Diego
    #5
    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.
     
  6. thread starter macrumors newbie

    Joined:
    Apr 16, 2009
    Location:
    The U S of A
    #6
    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.
     
  7. macrumors 6502

    Joined:
    Dec 2, 2005
    Location:
    San Diego
    #7
    heh... Are you trying to load it to an iPhone or are you using the simulator?
     
  8. thread starter macrumors newbie

    Joined:
    Apr 16, 2009
    Location:
    The U S of A
    #8
    To my iTouch. I guess I should do the simulator first.
     
  9. macrumors 6502

    Joined:
    Dec 2, 2005
    Location:
    San Diego
    #9
    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.
     
  10. thread starter macrumors newbie

    Joined:
    Apr 16, 2009
    Location:
    The U S of A
    #10
    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"];
    }
    
     
  11. macrumors 6502

    Joined:
    Dec 2, 2005
    Location:
    San Diego
    #11
    Going to need to see the entire syntax error.
     
  12. thread starter macrumors newbie

    Joined:
    Apr 16, 2009
    Location:
    The U S of A
    #12
    Line Location Pixel_Car_App_Prefix.pch:6: error: syntax error before '@' token
     
  13. macrumors 6502

    Joined:
    Dec 2, 2005
    Location:
    San Diego
    #13
    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.
     
  14. macrumors 6502

    mccannmarc

    Joined:
    Aug 15, 2008
    Location:
    Manchester, UK
    #14
    Another thing which stands out like a sore thumb:-

    what the hell is @implentation? I think you mean to put @implementation
     
  15. thread starter macrumors newbie

    Joined:
    Apr 16, 2009
    Location:
    The U S of A
    #15
    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
    
     
  16. macrumors 6502

    Joined:
    Dec 2, 2005
    Location:
    San Diego
    #16
    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.
     
  17. macrumors 6502

    mccannmarc

    Joined:
    Aug 15, 2008
    Location:
    Manchester, UK
    #17
    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
     
  18. Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #18
    (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.
     
  19. macrumors 603

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #19
    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
     
  20. macrumors regular

    Joined:
    Apr 9, 2009
    #20
    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.
     

Share This Page