• 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: Self describing NSObjects.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Self describing NSObjects.


  • Subject: Re: Self describing NSObjects.
  • From: Shazron <email@hidden>
  • Date: Thu, 05 Feb 2015 16:04:54 -0800

Similar to Seth's method:
https://github.com/phonegap/adobe-creative-sdk-foundation/blob/master/src/ios/NSObject+PropertiesAsDictionary.m
Then you could serialize the dictionary to a JSON string, and print that.

On Thu, Feb 5, 2015 at 3:54 PM, Seth Willits <email@hidden> wrote:
> On Feb 4, 2015, at 10:43 AM, Alex Zavatone <email@hidden> wrote:
>>
>> How would you think about implementing this?  It seems like I run into this need year after year after year.
>
>
> NSString * NSObjectDescriptionUsingProperties(id obj)
> {
>         unsigned int propCount;
>         objc_property_t * propList = class_copyPropertyList([obj class], &propCount);
>         NSMutableString * ms = [NSMutableString stringWithFormat:@"<%@: %p>", NSStringFromClass([obj class]), obj];
>         if (propCount > 0) {
>                 [ms appendString:@" {\n"];
>                 for (unsigned int i = 0; i < propCount; i++) {
>                         const char * propName = property_getName(propList[i]);
>                         [ms appendFormat:@"\t%s = %@,\n", propName, [obj valueForKey:[NSString stringWithUTF8String:propName]]];
>                 }
>                 [ms appendString:@"}"];
>                 free(propList);
>         }
>
>         return ms;
> }
>
>
>
>
> --
> Seth Willits
>
>
>
>
> _______________________________________________
>
> 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


References: 
 >Self describing NSObjects. (From: Alex Zavatone <email@hidden>)
 >Re: Self describing NSObjects. (From: Seth Willits <email@hidden>)

  • Prev by Date: Re: Self describing NSObjects.
  • Next by Date: Re: Networking framework crash
  • Previous by thread: Re: Self describing NSObjects.
  • Next by thread: Networking framework crash
  • Index(es):
    • Date
    • Thread