What is the best practice for parsing primitive type in iOS (int, float, BOOL etc.) while storing them in dataObjects for later use.
Should i parse it and store it as a NSNumber, or just store it as a primitive type property?
For example: if i'm getting 'userId' from server as long type. Should this be:
@property (nonatomic, strong) NSNumber *userId;
self.userId = [element objectForKey:@"user_id"];
or:
@property (nonatomic, assign) long userId;
self.userId = [[element objectForKey:@"user_id"] longValue];
Thanks.
In my view, it's a good practice to have it in primitive form as long as you will not indulge them in heavy operations. It's one less burden for the compiler. Of course, it doesn't even cost a clock-cycle for the processor. But, it gets efficient as you move on to bigger number of data.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With