Good day everyone! I would just want to ask what is wrong with what I am doing. I am working with this for two days and yet I still can’t make it. It says “unrecognized selector sent to instance 0x748b800”.
What I am doing is parsing a json returned value. Below is the sample json returned value:
{
"data": [
{
"name": "John Patola",
"id": "123444432"
},
{
"name": "Joshua Valdez",
"id": "22234567778"
}
]
}
I want to store them in an array called
NSArray *storage.
Below are my codes:
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
[self.rData appendData:data];
}
-(void)connection: (NSURLConnection *)connection didFailWithError:(NSError *)error{
[rData release];
[connection release];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection{
NSString *myVar = [[[NSString alloc] initWithData:rData encoding:NSUTF8StringEncoding] autorelease];
NSArray *storage =[[(NSDictionary *)myVar objectForKey:@"data"]retain]; // this line seems to be the error
NSLog(@"%i", [storage count]);
When I run this code, I got an error “unrecognized selector sent to instance 0x748b800”. Do you think that the line I’ve marked really gives error? How can I fix it? Thank you for your help in advance. 😉
Add
JSONkit in your project.Declare a method in your
viewController.hfileThen import
in your
viewController.mfile andThen parse your string here –