Re: A simple Objective-C question
Re: A simple Objective-C question
- Subject: Re: A simple Objective-C question
- From: "stephen joseph butler" <email@hidden>
- Date: Thu, 10 Apr 2008 13:55:11 -0500
On Thu, Apr 10, 2008 at 1:22 PM, Rama Krishna <email@hidden> wrote:
> However, such a class has a problem. It cannot be allocated or
> initialized.
> Because it can never get the alloc message as the alloc message is
> declared
> in the Object class. My question ,therefore, is how can such classes be
> instantiated. Is there a library function for that? Surely, the standard
> alloc function must be using such a function. Or should I just derive all
> classes from Object.
>
I could be wrong, but I think you can build a +alloc message using
NSAllocateObject. However, to make your class behave well with the rest of
Cocoa, you'll also need to implement a large part of the NSObject protocol.
Unless you have a very good reason (no offense, but beginners rarely do)
then you should inherit from NSObject instead.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden