我正在使用NSURLConnection
sendSynchronousRequest
下载数据,并在该声明中崩溃。
代码如下:
_url = [NSURL URLWithString:[urlString urlEncodeUsingEncoding:NSUTF8StringEncoding]];
_urlRequest = [[NSMutableURLRequest alloc] initWithURL:self.url];
NSHTTPURLResponse *response = nil;
NSError *error = nil;
if(![self isCancelled])
{
_receivedData = [NSURLConnection sendSynchronousRequest:_urlRequest returningResponse:&response
error:&error];
}
_error = error;
原因:
* 由于未捕获的异常而终止应用 'NSInvalidArgumentException',原因:' - [__ NSCFType URL]:无法识别 选择器发送到实例0x1cd2eaf0'
当我回溯时,我得到了这个:
- 线程#7:tid = 0x240f,0x397a1350 libsystem_kernel.dylib
__pthread_kill + 8, queue = 'com.apple.root.default-priority', stop reason = signal SIGABRT frame #0: 0x397a1350 libsystem_kernel.dylib
__ pthread_kill + 8 帧#1:0x39718122 libsystem_c.dylibpthread_kill + 58 frame #2: 0x39754972 libsystem_c.dylib
abort + 94 第3帧:0x38cf2d4e libc ++ abi.dylibabort_message + 74 frame #4: 0x38cefff8 libc++abi.dylib
default_terminate()+ 24 帧#5:0x392a3a76 libobjc.A.dylib_objc_terminate() + 146 frame #6: 0x38cf007a libc++abi.dylib
safe_handler_caller(void(*)())+ 78 帧#7:0x38cf0114 libc ++ abi.dylibstd::terminate() + 20 frame #8: 0x38cf1512 libc++abi.dylib
__ cxa_throw + 122 帧#9:0x392a39be libobjc.A.dylibobjc_exception_throw + 94 frame #10: 0x31626e06 CoreFoundation
- [NSObject(NSObject)doesNotRecognizeSelector:] + 170 帧#11:0x31625530 CoreFoundation___forwarding___ + 392 frame #12: 0x3157cf68 CoreFoundation
_ CF_forwarding_prep_0 + 24 帧#13:0x31f5e21e基金会+[NSURLConnection sendSynchronousRequest:returningResponse:error:] + 334 * frame #14: 0x001268d0 Rangeela
- [RGFeedOperation main](自我= 0x1cd35180, RGFeedOperation.m上的_cmd = 0x370c3394)+ 3284:90 帧#15:0x31eb05c0基金会-[__NSOperationInternal start] + 840 frame #16: 0x31f28be2 Foundation
__ block_global_6 + 102 帧#17:0x396bb11e libdispatch.dylib_dispatch_call_block_and_release + 10 frame #18: 0x396c9258 libdispatch.dylib
_ dispatch_root_queue_drain + 260 帧#19:0x396c93b8 libdispatch.dylib_dispatch_worker_thread2 + 84 frame #20: 0x396efa10 libsystem_c.dylib
_ pthread_wqthread + 360
有人可以帮我解决这个问题吗?
答案 0 :(得分:0)
查看错误消息,您尝试将方法发送给没有该方法的对象。仔细检查所有声明,确保将正确类型的对象发送到崩溃的例程中。您是否发送了需要NSURLResponse或NSURLConnection的NSURL?