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 (Cocoa-dev@lists.apple.com)
> 
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/davedelong%40me.com
> 
> This email sent to davedel...@me.com

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

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to