Created
January 13, 2015 06:25
-
-
Save zeayes/04f9c69dfdaaf062f6d3 to your computer and use it in GitHub Desktop.
http get example for objective
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 <Foundation/Foundation.h> | |
int main(int argc, const char *argv[]) { | |
@autoreleasepool { | |
NSError *error; | |
NSURL *url = [NSURL URLWithString: @"http://127.0.0.1:6100/user/10167/profile/"]; | |
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url | |
cachePolicy:NSURLRequestUseProtocolCachePolicy | |
timeoutInterval: 10]; | |
NSData *received = [NSURLConnection sendSynchronousRequest:request | |
returningResponse:nil | |
error:&error | |
]; | |
NSString *str = [[NSString alloc] initWithData:received | |
encoding:NSUTF8StringEncoding | |
]; | |
NSDictionary *data = [NSJSONSerialization JSONObjectWithData:received | |
options:kNilOptions | |
error:&error | |
]; | |
NSLog(@"json data: %@", data); | |
NSLog(@"%@", str); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment