gpt4 book ai didi

ios - NSURLConnection sendSynchronousRequest 在慢速网络上崩溃

转载 作者:行者123 更新时间:2023-12-01 17:22:48 27 4
gpt4 key购买 nike

我正在使用 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;

原因:

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType URL]: unrecognized selector sent to instance 0x1cd2eaf0'

当我回溯时我得到这个:

  • thread #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 frame #1: 0x39718122 libsystem_c.dylibpthread_kill + 58
    frame #2: 0x39754972 libsystem_c.dylib
    abort + 94 frame #3: 0x38cf2d4e libc++abi.dylibabort_message + 74
    frame #4: 0x38cefff8 libc++abi.dylib
    default_terminate() + 24 frame #5: 0x392a3a76 libobjc.A.dylib_objc_terminate() + 146
    frame #6: 0x38cf007a libc++abi.dylib
    safe_handler_caller(void (*)()) + 78 frame #7: 0x38cf0114 libc++abi.dylibstd::terminate() + 20
    frame #8: 0x38cf1512 libc++abi.dylib
    __cxa_throw + 122 frame #9: 0x392a39be libobjc.A.dylibobjc_exception_throw + 94
    frame #10: 0x31626e06 CoreFoundation
    -[NSObject(NSObject) doesNotRecognizeSelector:] + 170 frame #11: 0x31625530 CoreFoundation___forwarding___ + 392
    frame #12: 0x3157cf68 CoreFoundation
    _CF_forwarding_prep_0 + 24 frame #13: 0x31f5e21e Foundation+[NSURLConnection sendSynchronousRequest:returningResponse:error:] + 334 * frame #14:
    0x001268d0 Rangeela
    -[RGFeedOperation main](self=0x1cd35180, _cmd=0x370c3394) + 3284 at RGFeedOperation.m:90 frame #15: 0x31eb05c0 Foundation-[__NSOperationInternal start] + 840
    frame #16: 0x31f28be2 Foundation
    __block_global_6 + 102 frame #17: 0x396bb11e libdispatch.dylib_dispatch_call_block_and_release + 10
    frame #18: 0x396c9258 libdispatch.dylib
    _dispatch_root_queue_drain + 260 frame #19: 0x396c93b8 libdispatch.dylib_dispatch_worker_thread2 + 84
    frame #20: 0x396efa10 libsystem_c.dylib
    _pthread_wqthread + 360

有人可以帮我解决这个问题吗?

最佳答案

查看错误消息,您正在尝试将方法发送到没有该方法的对象。检查所有声明并确保将正确类型的对象发送到崩溃的例程。您是否在需要 NSURLResponse 或 NSURLConnection 的地方发送了 NSURL?

关于ios - NSURLConnection sendSynchronousRequest 在慢速网络上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24530939/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com