Created
January 6, 2014 02:19
-
-
Save Sunnyztj/8277208 to your computer and use it in GitHub Desktop.
Objective C connect with Rails servers
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
- (NSDictionary*) fetchMessageList:(NSInteger)pagenum { | |
NSString* urlstring = [NSString stringWithFormat:@"%@/api/v1/user/messages.json?page=%d", BaseURL, pagenum]; | |
NSLog(@"Message List URL : %@", urlstring); | |
NSURL* url = [NSURL URLWithString:urlstring]; | |
MBGetDataRequest* request = [MBGetDataRequest requestWithURL:url]; | |
[request applyHTTPHeaders:[NSDictionary dictionaryWithObjectsAndKeys: | |
[[MBPreferenceManager sharedPreferenceManager] getSecurityKey], | |
@"Http-X-User-Access-Token", | |
@"application/x-www-form-urlencoded", | |
@"Content-Type", nil]]; | |
[request startSynchronous]; | |
NSString* response = [request responseString]; | |
NSDictionary* retary=nil; | |
if (response) { | |
retary = [MBUtilities stringConvertToJSON:response]; | |
if ([self checkResponse:retary]) { | |
return retary; | |
} else { | |
return nil; | |
} | |
} | |
return retary; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment