1
我有一個包含在其中的用戶對象的自定義類對象:如何對象轉換爲JSON對象時,有內部對象
@interface Order : NSObject
@property (nonatomic, retain) NSString *OrderId;
@property (nonatomic, retain) NSString *Title;
@property (nonatomic, retain) NSString *Weight;
@property (nonatomic, retain) User *User
- (NSMutableDictionary *)toNSDictionary;
...
- (NSMutableDictionary *)toNSDictionary
{
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
[dictionary setValue:self.OrderId forKey:@"OrderId"];
[dictionary setValue:self.Title forKey:@"Title"];
[dictionary setValue:self.Weight forKey:@"Weight"];
return dictionary;
}
在toNSDictinary
功能我沒有映射User
對象。
在這種情況下將對象轉換爲nsdictionary
的好方法是什麼?
與烏爾問題明確設置字典密鑰嘗試 – Chandru