Re: Newbie question regarding Learning Cocoa
Re: Newbie question regarding Learning Cocoa
- Subject: Re: Newbie question regarding Learning Cocoa
- From: Fatih Erarslan <email@hidden>
- Date: Mon, 4 Jun 2001 15:05:19 -0500
Hello Philippe,
I recommend you to read the first chapter of the book and also read the
Cocoa documentation in the /Developer/Documentation/Cocoa/
There is a nice PDF book in there, "Inside Cocoa" it's highly
recommended.
One thing ObjC is self explanatory, many method names are predefined in
the Cocoa classes. "id" is the replacement of static typing of
objects so your app
can find it's class in the runtime.
~Fatih
Monday, June 04, 2001, 9:17:54 AM, you wrote:
PdR> Hello,
PdR> I am currently working through O'Reilly's Learning Cocoa and have
PdR> problems understanding the following Obj-C code:
PdR> On p. 55 :
PdR> NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
PdR> NSLog(@"Hello world");
PdR> [pool release];
PdR> What is the purpose of creating an autorelease pool in the code above if
PdR> you are simply printing 'Hello World' onscreen?
PdR> On page 136,
PdR> #import "DotView.h"
PdR> @implementation DotView
PdR> - (id)initWithFrame: (NSRect)frame
PdR> {
PdR> self = [super initWithFrame:frame];
PdR> center.x = 50.0;
PdR> center.y = 50.0;
PdR> radius = 10.0;
PdR> color = [[ NSColor redColor] retain]; why do you retain the new
PdR> NSColor object?
PdR> return self; why do you retain 'self'? Why do you return
PdR> it in an 'id'?
PdR> }
PdR> - (void)dealloc
PdR> {
PdR> [color release];
PdR> [super dealloc]; what is DotView's parent, which you must
PdR> dealloc? Does deallocing simply mean calling DotView's parent's
PdR> dealloc method?
PdR> }
PdR> - (void)awakeFromNib
PdR> {
PdR> [colorWell setColor: color]; how can you be sure here that
PdR> 'color' points to an existing object? Did you retain it somewhere else?
PdR> [sizeSlider setFloatValue:radius];
PdR> }
PdR> @end
PdR> -(void)awakeFromNib {
PdR> ...
PdR> [[NSColor whiteColor] set] why don't you retain the new
PdR> whiteColor object here, as you did above?
PdR> ...
PdR> -(void)drawRect: (NSRect)rect {
PdR> ...
PdR> [[NSColor whiteColor] set] what is 'set'? Was it predefined somewhere?
PdR> p. 158:
PdR> return [NSCalendarDate date] what is 'date'? Is it a function?
PdR> Any help with the above would be much appreciated.
PdR> Philippe de Rochambeau
PdR> _______________________________________________
PdR> cocoa-dev mailing list
PdR> email@hidden
PdR>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
--
Best regards,
Fatih
mailto:email@hidden