Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to get a dictionary of NSObject attribute names and values

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

During recent development with SBJSON, it was discovered that SBJSON could not support custom objects, and two implementation scenarios were considered. A way to implement a custom object's Category at layer one of the SBJSON framework to support proxyForJson. Another option is for the application layer to convert custom objects into dictionaries of attribute names and attribute values, which are then processed by SBJSON. Since SBJSON is maintained by an underlying library, the compromise is to handle custom objects at the application level. After some investigation and searching, we found the following implementation methods:

#import #import @interface NSObject (PropertyListing)// aps suffix to avoid namespace collsion// ... for Andrew Paul Sardone- (NSDictionary *)properties_aps;@end@implementation NSObject (PropertyListing)- (NSDictionary *)properties_aps {NSMutableDictionary *props = [NSMutableDictionary dictionary];unsigned int outCount, i;objc_property_t *properties = class_copyPropertyList([self class], &outCount);for (i = 0; i

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report