Mantle / Mantle

Model framework for Cocoa and Cocoa Touch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to set NSInteger property in model

SayHelloToWorld opened this issue · comments

Hi, I have a problem using NSInteger, it seems that the support for int is limited.
My model here:

@interface Feed : MTLModel <MTLJSONSerializing>

@property (assign, nonatomic, readonly) NSInteger likes;    
@property (strong, nonatomic, readonly) NSString *imageURL;

@end

And the blocks in method transformerUsingForwardBlock is id input and id output, but NSInteger is a Primitive type, How should I transform this NSInteger?

Mantle uses Key Value Coding, using NSNumber for the likes property should do the trick, you can find more in the Representing Non-Object Values section of the Key-Value Coding Programming Guide.

Feel free to reopen this if you have further questions.