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

reziasultana

macrumors newbie
Original poster
Apr 4, 2012
2
0
Hi

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:

Code:
- (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

Rezia
 
Last edited by a moderator:
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
 
It looks like your missing the ';' at the end of this line

Code:
myMessage=[[UILabel alloc]
	initwithframe: CGRectMake((25,225,300,50)]
 
Last edited by a moderator:
Code:
- (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;

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

In this:
Code:
	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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.