A first version of an extension to Realm.io for working with JSON based Rest API's
Realm-Rest is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "Realm-Rest"
[realm setBaseUrl:@"http://api.example.com" queuePersistance:RestRequestQueuePeristanceDatabase];
@interface User : RLMObject
@property NSString* username;
@property NSString* name;
@end
[User restInDefaultRealmWithRequestType:RestRequestTypePost
parameters:@{
RestRequestParameterStyleJSON : @{
”username”:”foo”,
”password”:”bar”
}}
headers:nil
userInfo:@{@"action":@"login"}
success:^(id primaryKey) {
User *user = [User objectForPrimaryKey:primaryKey];
//Use object
}
failure:^(NSError *error, NSDictionary *userInfo) {
//Handle error
}
];
Se the Wiki for more details on how to use Realm-Rest
Tobias Sundstrand, tobias.sundstrand@gmail.com
Realm-Rest is available under the MIT license. See the LICENSE file for more info.