Re: Object allocation question
Re: Object allocation question
- Subject: Re: Object allocation question
- From: Scott Stevenson <email@hidden>
- Date: Sun, 29 Oct 2006 22:17:29 -0800
On Oct 29, 2006, at 8:50 PM, Michael Latta wrote:
But, would it work in Obj-C? Or must each object individually go
through
alloc/init to function properly?
For now, it's not required.
You can malloc a large block and just populate the isa pointers in
the appropriate places instead of doing -alloc for each one. I'm not
sure about how much success you'd have with trying to skip -init,
though.
I remember getting some errors when trying to access the isa pointer,
and I got around it by doing this:
id theObject = class_createInstance(NSClassFromString
(className), sizeof(unsigned));
id objectAlias = theObject;
For some reason, I was able to change the value of objectAlias->isa,
when I couldn't change it for theObject. All of this could change at
any time, which is probably why it generates errors.
- Scott
_______________________________________________
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