Re: Self describing NSObjects.
Re: Self describing NSObjects.
- Subject: Re: Self describing NSObjects.
- From: Richard Heard <email@hidden>
- Date: Wed, 04 Feb 2015 20:38:50 -0800
Or you can call _ivarDescription on the object in question.
-R
> On 4 Feb 2015, at 10:54:49 AM, Pascal J. Bourguignon <email@hidden> wrote:
>
>
>> On 04 Feb 2015, at 19:43, Alex Zavatone <email@hidden> wrote:
>>
>> All too often, I have a simple data class that is just a bunch of properties of cocoa collections.
>>
>> When walking through the debugger, it would be nice if these classes could auto describe.
>>
>> Consider this. I have a class with the properties of NSStrings that are firstname, lastname, address.
>>
>> Calling description or debugDescription on an instance of the class simply prints out the memory location.
>>
>> Is there something that I'm missing here? I don't want to manually enter each of the names of each of the properties to be exposed through a description method. Is there a means to extend NSObject to auto describe the top level of properties that are NSStrings, NSDictionaries, NSSets and so on and automatically dump them to the console?
>>
>> How would you think about implementing this? It seems like I run into this need year after year after year.
>
> Have a look at:
> https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/index.html#//apple_ref/doc/uid/20000050-SW25
>
> You can obtain the attributeKeys, and from there, obtain the value of the attributes and therefore implement a -description and/or -debugDescription including them.
>
> --
> __Pascal J. Bourguignon__
>
>
>
> _______________________________________________
>
> 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
_______________________________________________
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