• 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: Trouble calling class_addIvar()
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trouble calling class_addIvar()


  • Subject: Re: Trouble calling class_addIvar()
  • From: Dave DeLong <email@hidden>
  • Date: Fri, 08 Oct 2010 17:42:28 -0600

I think you can only use class_addIvar() in between corresponding calls to objc_allocateClassPair() and objc_registerClass().

Docs: http://developer.apple.com/library/ios/documentation/cocoa/reference/ObjCRuntimeRef/Reference/reference.html#//apple_ref/doc/uid/TP40001418-CH1g-SW10

Dave

On Oct 8, 2010, at 5:39 PM, Rick Mann wrote:


> I'm trying to add an ivar to a (sub)class in the base class' +initialize method. I'm not sure if it's too late to do it at this point or not. If I can't do it here, i don't know where to make the call.
>
> I'm calling it like this:
>
> 	char const* ivarNameCString = ivarName.UTF8String;
>
> 	size_t size = sizeof (NSData*);
> 	uint8_t align = log2(size);
> 	bool success = class_addIvar(self.class, ivarNameCString, size, align, "@");
>
> The values for the parameters end up being:
>
> ivarNameCString:	mOutputDataCacheChannel1
> size:			8
> align:			3
>
> The documentation doesn't specify what the last parameter should be, other than to name it "types." I assumed that was supposed to be a type string, although I don't know why you would specify more than one.
>
> Anyway, this returns false, but I have no idea why.
>
> Can anyone help me out? Thanks!
>
> --
> Rick
>
> _______________________________________________
>
> 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

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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

References: 
 >Trouble calling class_addIvar() (From: Rick Mann <email@hidden>)

  • Prev by Date: Re: Trouble calling class_addIvar()
  • Next by Date: Re: Trouble calling class_addIvar()
  • Previous by thread: Re: Trouble calling class_addIvar()
  • Next by thread: main window disappears on resize
  • Index(es):
    • Date
    • Thread