I want to retrieve the username of the member who publish something in Facebook with my iPhone App. I got it but in bad format. My code :
//My method
- (void)request:(FBRequest *)request didReceiveResponse:(NSURLResponse *)response {
NSLog(@"received response %@",response);
//The callback
[_facebook requestWithGraphPath:@"https://graph.facebook.com/me" andDelegate:self];
And i got this in GDB:
received response <NSHTTPURLResponse: 0x1a11e0>
What's the format : JSON i think but how can i t开发者_开发知识库ransform it in a simple NSString ?
Thanks
Flo.
You are using the wrong method to access the response. You are using a method from the NSURLConnection delegate protocol.
You should implement the following methods as well:
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
This method can be called many times, so you'd like to add the incoming data to a NSMutableData instance.
and
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
which will tell you that loading of the data has finished, your response is complete.
When the received data is complete you can create a string with it with.
- (id)initWithData:(NSData *)data encoding:(NSStringEncoding)encoding
I'd recommend a JSON Framework to parse json strings.
You can try with JSON-Framework for parsing JSON.
Anyway... you should look at the NSURLResponse Class Reference...
精彩评论