• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Object allocation question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Object allocation question
      • From: Scott Stevenson <email@hidden>
References: 
 >Object allocation question (From: "Michael Latta" <email@hidden>)

  • Prev by Date: Export resolution of an Image
  • Next by Date: Question regarding NSView's drawRect
  • Previous by thread: Object allocation question
  • Next by thread: Re: Object allocation question
  • Index(es):
    • Date
    • Thread