Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joshdholtz/restcat
A RESTful library for iOS
https://github.com/joshdholtz/restcat
Last synced: 10 days ago
JSON representation
A RESTful library for iOS
- Host: GitHub
- URL: https://github.com/joshdholtz/restcat
- Owner: joshdholtz
- Created: 2012-04-01T16:19:18.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-04-01T16:40:43.000Z (over 12 years ago)
- Last Synced: 2024-10-11T10:32:50.909Z (about 1 month ago)
- Language: Objective-C
- Homepage:
- Size: 121 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
RestCat
=========Examples - Basic
-----------###Set base url
[[RestCat sharedInstance] setBaseURL:@"http://example.com"];### Make request
[[RestCat sharedInstance] doGet:@"/member" params:nil withBlock:^(NSUInteger status, NSData *data){} ];
###Make JSON request
[[RestCat sharedInstance] doGetAsJSON:@"/member/2" params:nil withBlock:^(NSUInteger status, id jsonData){
if ([jsonData isKindOfClass:[NSDictionary class]]) {} else if ([jsonData isKindOfClass:[NSArray class]]) {
}
} ];Examples - Models
-----------
###Model - Member.h
#import "RestCatObject.h"@interface Member : RestCatObject
@property (nonatomic, strong) NSString* firstName;
@end
###Model - Member.m
#import "Member.h"@implementation Member
@synthesize firstName = _firstName;
- (NSDictionary *)mapKeysToProperties {
return [[NSDictionary alloc] initWithObjectsAndKeys:
@"firstName", @"first_name",
nil ];
}@end
###Creating and Using Model - SomeOtherClass.m
[[RestCat sharedInstance] doGetAsJSON:@"/member/2" params:nil withBlock:^(NSUInteger status, id jsonData){if ([jsonData isKindOfClass:[NSDictionary class]]) {
Member *member = [[Member alloc] initWithDictionary:jsonData];
NSLog(@"First Name - %@", [member firstName]);
}} ];