While deploying my application, I got the error message: “Thread 1:Program received signal: “EXC_BAD_ACCESS”.
My code is below:
-(NSDictionary *)syncWithList:(NSInteger)listID
{
NSString *urlit = [NSString stringWithFormat:@"http://0.0.0.0:3000/lists/%@/syncList.json?auth_token=%@",@"xxxxxxxxxxx",listID];
// **Here I got the error message: "Thread 1:Program received signal: "EXC_BAD_ACCESS"**
NSLog(@"url: %@",urlit);
NSURL *freequestionurl = [NSURL URLWithString:urlit];
ASIHTTPRequest *back = [ASIHTTPRequest requestWithURL:freequestionurl];
[back startSynchronous];
self.listData = [[back responseString] objectFromJSONString];
NSLog(@"%@",listData);
NSDictionary *dicPost = [listData objectAtIndex:0];
return dicPost;
}
Thanks a lot!!!!
You must not format
NSInteger(which is just a typedef’dinton current iOS versions) with the%@specifier. Writing%@in a string format basically means “calldescriptionon the object and use the result”.But NSInteger is not an object, it’s a primitive type.
You get a memory exception because when listID is 42 you access an object at memory address 42. This is definitely not what you want.
just use the
%iformat specifier instead of%@for listID.