在部署我的应用程序时,我收到错误消息:"线程1:程序接收信号:"EXC_BAD_ACCESS".
我的代码如下:
-(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;
}
非常感谢!!!!
Mat*_*uch 12
您不能使用说明符格式化NSInteger(这只是int当前iOS版本上的typedef )%@.%@以字符串格式书写基本上意味着"调用description对象并使用结果".
但NSInteger不是一个对象,它是一种原始类型.
你得到一个内存异常,因为当listID是42时,你访问内存地址42的对象.这绝对不是你想要的.
-(NSDictionary *)syncWithList:(NSInteger)listID
                               ^^^^^^^^^
NSString *urlit = [NSString stringWithFormat:@"http://0.0.0.0:3000/lists/%@/syncList.json?auth_token=%@",@"xxxxxxxxxxx",listID];
                                                                                                     ^^
只使用%i格式说明符而不是%@listID.
NSString *urlit = [NSString stringWithFormat:@"http://0.0.0.0:3000/lists/%@/syncList.json?auth_token=%i",@"xxxxxxxxxxx",listID];
| 归档时间: | 
 | 
| 查看次数: | 4388 次 | 
| 最近记录: |