I have a class that has bloated with properties, and now there are about 30 of them, most of which are integer enumerated types.
My code currently uses this in several places, and I try to gently navigate the new dictionary view.
I want to create a dictionary from this object, but include only values ββthat are not 0 (values ββthat contain some data).
Is there some objective-c key value encoding mask that can help me simplify writing this method?
@property(nonatomic)kGrade grade;
@property(nonatomic)kQuality quality;
-(NSMutableDictionary*)itemAsDictionary
{
if(itemDictionary !=nil)
{
return itemDictionary;
}else
{
itemDictionary = [[NSMutableDictionary alloc] initWithCapacity:40];
if(self.grade>0)
{
[itemDictionary setObject:@(self.grade) forKey:@"grade"];
}
}
return itemDictionary;
}
source
share