Created
March 16, 2013 15:35
-
-
Save halsk/5176915 to your computer and use it in GitHub Desktop.
サーバの JSON テキストから Objective-C のインスタンスを生成するライブラリ、SimpleRemoteObject を公開しました。 ref: http://qiita.com/items/049b9c4584769fe37896
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[User fetchAsync:^(NSArray *allRemote, NSError *error) { | |
if (error){ | |
//Do error handling | |
}else{ | |
for (User* user in allRemote){ | |
NSLog(@"my name is:%@",user.name); | |
} | |
} | |
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <SimpleRemoteObject/SRSimpleRemoteObject.h> | |
@interface User : SRSimpleRemoteObject | |
@property(nonatomic,retain) NSString *name; | |
@property(nonatomic,retain) NSString *email; | |
@property(nonatomic) int age; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "User.h" | |
@implementation Tag | |
+(NSString *)representUrl{ | |
return @"users.json"; // server path | |
} | |
+(NSString *)resultKey{ | |
return @"objects"; // key of target JSON object | |
} | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
meta: { | |
limit: 20, | |
next: null, | |
offset: 0, | |
previous: null, | |
total_count: 3 | |
}, | |
objects: [ | |
{ | |
id: 2, | |
name: "Daniel", | |
email: "daniel@example.com", | |
age: 25 | |
}, | |
{ | |
id: 2, | |
name: "Mario", | |
email: "mario@example.com", | |
age: 30 | |
}, | |
{ | |
id: 3, | |
name: "Hal", | |
email: "hal@example.com", | |
age: 32 | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <SimpleRemoteObject/SRSimpleRemoteObject.h> | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
[SRRemoteConfig defaultConfig].baseurl = SERVER_URL; | |
// Override point for customization after application launch. | |
return YES; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment