PLEASE HELP. Just starting out.

Discussion in 'iPhone/iPad Programming' started by Abunga, Jan 25, 2011.

  1. macrumors newbie

    Abunga

    #1
    Hello, I have jut started using Objective-C and Object Oriented programming in general. Could somebody please help me with this somewhat simple coding?

    Code:
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
        
        // Override point for customization after application launch.
    	
        UILabel *myMessage;
    	
    	int value1;
    	int value2;
    	value1 = 10;
    	value2 = value1 * 2;
    	
    	myMessage=[[UILabel alloc] initWithFrame:CGRectMake(25,225,300,50)];
    	NSLog(@"The value is %d.", value2);	
    	[window addSubview:myMessage];
    	[window makeKeyAndVisible];
    	
    	return YES;
    }
    
    Although this is relatively simple in programming terms, i am trying to make it so that the NSLog I create will show up on the IPhone screen and not just in the console window. In other words, what needs to be used instead of NSLog etc.

    Sorry it's a bit basic, but after years of working with languages like Basic, C has always bewildered me. This answer seems to specific for books to answer.

    Thanks for any help you can give me.

    Abunga. :(
     
  2. Moderator

    balamw

    Staff Member

    #2
    What books are you using?

    By the time you get to Cocoa Touch, this should be handled.

    e.g. if you are working through Kochan's book work through the iPhone fraction calculator and you should be able to figure it out.

    (hint, you need to build an interface)

    B
     
  3. macrumors newbie

    Abunga

    #3
    Mmmmm, thanks.

    Thanks for the response. I am using, amongst online resources, a SAMS Teach Yourself book and I also have Objective C for Dummies as a reference.

    I know that you have to build an interface, and have done, but can't understand how to make the label show the variable.

    Mmmmmm, it become cloudier by the day.

    Cheers.

    Abunga. :confused:
     
  4. Moderator

    dejo

    Staff Member

    #4
    Do your books cover how to make a UILabel show any text? Once you're comfortable with that concept, you can move on to getting your label to show specific text. Then, from there, it's on to realizing that what NSLog takes (mainly) as an argument is pretty much the same as what setting a label's text does.
     
  5. Moderator

    balamw

    Staff Member

    #5
    Is this the SAMS book? http://www.amazon.com/Teach-Yoursel...=sr_1_1?ie=UTF8&s=books&qid=1296073977&sr=1-1 If so, it shows you what to do both in Chapter 2 and Chapter 5.

    The Objective C for Dummies book gets lousy ratings on Amazon, so I'll ignore it.

    B
     
  6. macrumors newbie

    Abunga

    #6
    Thanks...

    Thanks for the help given peeps, probably obvious really, from your perspective.

    Will look into other books too. SAMS is very good generally, and yes, the Dummies book is the same as all other Dummies books in that never pushes far enough when you want to know something.

    Cheers again.

    (Don't suppose anybody knows how you put a signature on to postings in this forum? Have tried and failed.)
     
  7. Moderator

    dejo

    Staff Member

    #7
    User CP (left side in the menu bar near the top of the page) > Edit Signature
     
  8. macrumors newbie

    Abunga

    #8
    Excellent.

    Thanks dejo.

    Abunga.
     

Share This Page