Tuesday, July 22, 2008

iPhoneFirst

Hey!

Although I haven't finished the Obj-C guide I headed to the example. I just couldn't bear it anymore.

XCode basically does everything for us. I just displayed the nice Hello World!.

Simple commands so to speak:

Delegate:

MyView *view = [[MyView alloc] initWithFrame:[window frame]];
[window addSubview:view];
[view release];

View:

- (void)drawRect:(CGRect)rect {
/* Draw "Hello, World!" */
NSString *hello = @"Hello, World!";
CGPoint location = CGPointMake(30, 30);
UIFont *font = [UIFont systemFontOfSize:24];
[[UIColor whiteColor] set];
[hello drawAtPoint:location withFont:font];

}

Yes, it is an instance method. We can more or less know what the snippet tells right? We've got the casting method, declaring @"" as String and so on. Perhaps the doubt is

CGPoint location = CGPointMake(30, 30);

why? Where is the *? Perhaps it ain't a pointer and it is in fact some sort of common object assignation.

That'd be all. I'll keep reading now.

One last thing...how can I do this when everyone isn't asleep. I should be resting my 8 hours but then I feel useless since I didn't give it a try the whole day.

0 comments: