Ich habe eine Klasse-Objekt in NSDictionaryWie konvertiert man ein Klassenobjekt in ein NSDictionary?
Ich habe folgende Klasse
@interface FoodMeal : NSObject<NSCoding,NSCopying>
@property (nonatomic,strong) NSString *mealType;
@property (nonatomic,strong) NSString *mealName;
@property (nonatomic,strong) NSArray *mealItems;
@property (nonatomic,strong) NSDate *mealDate;
@end
mealItems enthält FoodItems zu konvertieren, die ein Klassenobjekt ist.
FoodItems hat eine Variable Nährwerte, die ein Klassenobjekt internieren.
Gibt es eine effiziente Möglichkeit, die FoodMeal-Klasse in NSDictionary umzuwandeln.
Vielen Dank im Voraus.
dies sehen, wenn Sie Ideen erhalten http: // Stackoverflow .com/questions/19079862/converting-nsobject-to-nsdictionary –
Ich habe diese Lösung gesehen ... Ich muss manuell alle Inhalte zum Wörterbuch hinzufügen? Gibt es eine andere effiziente Lösung? –
Sie könnten versuchen [alle Eigenschaften Namen] (http://stackoverflow.com/questions/780897/how-do-i-find-all-the-property-keys-of-) a-kvc-compliant-objective-c-object) und dann mit 'valueForKey:' ihren Wert erhalten. – Droppy