Newbie question on Methods
Newbie question on Methods
- Subject: Newbie question on Methods
- From: "Bobby B" <email@hidden>
- Date: Sun, 12 Mar 2006 12:10:44 -0400
Hello there, this is my first post so let me introduce myself. I
working through some of the beginner exercises on Cocoadev.com. I
have a lot of past experience developing simple applications (medical
billing, etc) for the PC in Delphi. This is my "entrance" to
ObjC/Cocoa/MacOSX programming. I have a pretty decent understanding
of C. I've read the majority of Apple's document "Introduction to
Objective C".
There is one concept I'm not understanding. In the
NSOpenPanelWithFileTypes example (on CocoaDev.com) there is the following code:
NSArray *fileTypes = [NSArray arrayWithObject:@"td"];
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
I understand that in the first line you are declaring an instance of
the class (fileTypes) of the NSArray object. But I don't understand
the part that follows it. Why do you send the message to the NSArray
instead of to the fileTypes class? And the same question follows for
the NSOpenPanel right below it.
I was using the following code for the NSOpenPanel:
NSOpenPanel * op;
op = [[NSOpenPanel alloc] init];
How is that functionally different from:
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
Is it something regarding object methods and instance methods? To
further obfuscate my question, when do you have to do the [[Receiver
alloc] init] method? I notice when you declare a string : NSString *
myString =@"This is my string"; you don't have to run [[NSString
alloc] init]; on it. Why is this?
Thank you kindly
Bobby B
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden