ibireme/YYModel — an open-source project — sits at 4.3k GitHub stars. High performance model framework for iOS/OSX.
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
High performance model framework for iOS/OSX.
(It's a component of YYKit)
Performance
Time cost (process GithubUser 10000 times on iPhone 6):
See Benchmark/ModelBenchmark.xcodeproj for more benchmark case.
Features
High performance: The conversion performance is close to handwriting code.
Automatic type conversion: The object types can be automatically converted.
Type Safe: All data types will be verified to ensure type-safe during the conversion process.
Non-intrusive: There is no need to make the model class inherit from other base class.
Lightwight: This library contains only 5 files.
Docs and unit testing: 100% docs coverage, 99.6% code coverage.
Usage
Simple model json convert
// JSON:
{
"uid":123456,
"name":"Harry",
"created":"1965-07-31T00:00:00+0000"
}
// Model:
@interface User : NSObject
@property UInt64 uid;
@property NSString *name;
@property NSDate *created;
@end
@implementation User
@end
// Convert json to model:
User *user = [User yy_modelWithJSON:json];
// Convert model to json:
NSDictionary *json = [user yy_modelToJSONObject];
If the type of an object in JSON/Dictionary cannot be matched to the property of the model, the following automatic conversion is performed. If the automatic conversion failed, the value will be ignored.
JSON/Dictionary
Model
NSString
NSNumber,NSURL,SEL,Class
NSNumber
NSString
NSString/NSNumber
C number (BOOL,int,float,NSUInteger,UInt64,...)
NaN and Inf will be ignored
NSString
NSDate parsed with these formats:
yyyy-MM-dd
yyyy-MM-dd HH:mm:ss
yyyy-MM-dd'T'HH:mm:ss
yyyy-MM-dd'T'HH:mm:ssZ
EEE MMM dd HH:mm:ss Z yyyy
NSDate
NSString formatted with ISO8601:
"YYYY-MM-dd'T'HH:mm:ssZ"
You can map a json key (key path) or an array of json key (key path) to one or multiple property name. If there's no mapper for a property, it will use the property's name as default.
Nested model
// JSON
{
"author":{
"name":"J.K.Rowling",
"birthday":"1965-07-31T00:00:00+0000"
},
"name":"Harry Potter",
"pages":256
}
// Model: (no need to do anything)
@interface Author : NSObject
@property NSString *name;
@property NSDate *birthday;
@end
@implementation Author
@end
@interface Book : NSObject
@property NSString *name;
@property NSUInteger pages;
@property Author *author;
@end
@implementation Book
@end
Container property
@class Shadow, Border, Attachment;
@interface Attributes
@property NSString *name;
@property NSArray *shadows; //Array<Shadow>
@property NSSet *borders; //Set<Border>
@property NSMutableDictionary *attachments; //Dict<NSString,Attachment>
@end
@implementation Attributes
+ (NSDictionary *)modelContainerPropertyGenericClass {
// value should be Class or Class name.
return @{@"shadows" : [Shadow class],
@"borders" : Border.class,
@"attachments" : @"Attachment" };
}
@end
TopGit's last sync did not record any GitHub topics for ibireme/YYModel. GitHub topics appear in the right sidebar of a repository page; that's the authoritative place to check.
How active is development on ibireme/YYModel?
The most recent commit recorded on ibireme/YYModel was 3.9 years ago, based on the GitHub push timestamp. The repository has 922 forks — one of the better signals of community interest.
How many stars does ibireme/YYModel have?
ibireme/YYModel has 4.3k GitHub stars — refresh the page for the live number, or check github.com/ibireme/YYModel. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
What language is ibireme/YYModel written in?
ibireme/YYModel is written primarily in Objective-C. GitHub's language field is based on the largest share of bytes in the default branch.
Where do I read more about ibireme/YYModel?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/ibireme/YYModel is the definitive source.
Read full README in the tab above.
Still deciding about YYModel?
One click hands the question to an AI along with this page — see what it says about YYModel.