Help with simple code

Discussion in 'iOS Programming' started by reziasultana, Apr 4, 2012.

  1. reziasultana, Apr 4, 2012
    Last edited by a moderator: Apr 4, 2012

    reziasultana macrumors newbie

    Apr 4, 2012

    I'm a beginner in learning how to develope iphone apps. I am going through a tutorial to do my first code and am running into errors which I don't understand. I have copied the code from the tutorial several times and still can't build the app. The code is:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
    	UILabel *myMessage;
    	myMessage=[[UILabel alloc]
    	initwithframe: CGRectMake((25,225,300,50)]
    	myMessage.text@"Hello Xcode";
    	myMessage.font[UIFont systemfontofsize:48];
    	[window addSubview:myMessage];
    	[myMessage release];
        [self.window makeKeyAndVisible];
        return YES;
    I am getting expected with token error message on the 5th, 6th and 7th line

    Please can someone help.

    Thanks in advance

  2. robbieduncan Moderator emeritus


    Jul 24, 2002
    1) Which tutorial
    2) What do you understand the code does, line by line. Copy and pasting without thinking and understanding will teach you absolutely nothing
  3. cMacSW, Apr 4, 2012
    Last edited by a moderator: Apr 4, 2012

    cMacSW macrumors regular

    Mar 20, 2006
    It looks like your missing the ';' at the end of this line

    myMessage=[[UILabel alloc]
    	initwithframe: CGRectMake((25,225,300,50)]
  4. chown33 macrumors 604

    Aug 9, 2009
    You haven't copied the code very well. Or the original code is missing some crucial things.

    In this:
    	myMessage=[[UILabel alloc]
    	initwithframe: CGRectMake((25,225,300,50)][COLOR="Red"];[/COLOR]
    You're missing a semicolon (I added it in red).

    And letter case is important, so should it be initwithframe, or initWithFrame, or something else?

    Details are important in programming. Like punctuation and letter case. Focus on them. One way is to use a large font so you can more easily see exactly what you typed. Compare it carefully to what it should be. Apply that focus to the rest of your program, line by line.
  5. jonnymo5 macrumors 6502

    Jan 21, 2008
    The parenthesis in the CGRectMake dont match up either. You have 2 (( and only 1 ).

Share This Page