Re: Adding Properties to NKIssue?
Re: Adding Properties to NKIssue?
- Subject: Re: Adding Properties to NKIssue?
- From: Charles Srstka <email@hidden>
- Date: Wed, 04 Jul 2012 22:17:59 -0500
On Jul 4, 2012, at 8:30 PM, Conrad Shultz wrote:
> On 7/4/12 2:27 PM, Dave wrote:
>> Hi,
>>
>> That's more or less what we have at the moment and I think it's just
>> fine and probably better in the long run. However someone else thinks it
>> would be a better idea to do it my extending NKIssue if it is possible,
>> but it seems it's not, since there is no way I can see of actually
>> storing the property value anywhere, since you can't add iVar's.
>
> A workaround in situations where you need to add storage is to use
> associated objects.
>
> See
> http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/objectivec/Chapters/ocAssociativeReferences.html
> and the Objective-C run-time reference for details.
>
> It's really quite easy, and since NKIssue is only in iOS 5 and newer you
> don't have any backward compatibility issues.
>
> Note that you will need to import <objc/runtime.h> for the functions.
While that’s true, it’s a much less elegant solution than just using an object, as you are doing.
Charles
_______________________________________________
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