PDA

View Full Version : PLEASE HELP. Just starting out.




Abunga
Jan 25, 2011, 04:06 AM
Hello, I have jut started using Objective-C and Object Oriented programming in general. Could somebody please help me with this somewhat simple coding?


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



balamw
Jan 25, 2011, 06:27 AM
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

Abunga
Jan 26, 2011, 01:25 PM
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:

dejo
Jan 26, 2011, 01:33 PM
I know that you have to build an interface, and have done, but can't understand how to make the label show the variable.
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.

balamw
Jan 26, 2011, 02:35 PM
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.

Is this the SAMS book? http://www.amazon.com/Teach-Yourself-iPhone-Application-Development/dp/0672332205/ref=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

Abunga
Jan 27, 2011, 01:02 PM
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.)

dejo
Jan 27, 2011, 01:06 PM
(Don't suppose anybody knows how you put a signature on to postings in this forum? Have tried and failed.)
User CP (left side in the menu bar near the top of the page) > Edit Signature

Abunga
Jan 27, 2011, 01:54 PM
Thanks dejo.

Abunga.