gpt4 book ai didi

iphone - 推送 View Controller 时应用程序崩溃,[NSConcreteData initWithContentsOfURL :options:error:]: nil URL argument'

转载 作者:行者123 更新时间:2023-11-29 03:39:00 25 4
gpt4 key购买 nike

我收到错误

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:'-[NSConcreteData initWithContentsOfURL:options:error:]: nil URL argument'`

当我尝试将 viewControllerViewControllerA 推送到 ViewControllerB 时,应用程序崩溃

下面是我在ViewControllerB中的代码,

dispatch_queue_t concurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
//this will start the image loading in bg
dispatch_async(concurrentQueue, ^{
NSError *nserror = nil;
NSData *imageData = [NSData dataWithContentsOfURL:url options:NSDataReadingUncached error:&nserror];
//this will set the image when loading is finished
dispatch_async(dispatch_get_main_queue(), ^{
if (nserror) {

UIImage *image = [UIImage imageNamed:@"prod_img3.png"];
pro_image.image = image;
}
else{
UIImage *image = [UIImage imageWithData:imageData];
pro_image.image = image;
}
[self doneChecking];
});
});

我做错了什么?感谢您的帮助。

最佳答案

dispatch_queue_t concurrentQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
//this will start the image loading in bg
dispatch_async(concurrentQueue, ^{
NSError *nserror = nil;
if(url.length == 0)
{
UIImage *image = [UIImage imageNamed:@"prod_img3.png"];
pro_image.image = image;
}
else
{
NSData *imageData = [NSData dataWithContentsOfURL:url options:NSDataReadingUncached error:&nserror];
//this will set the image when loading is finished
dispatch_async(dispatch_get_main_queue(), ^{
if (nserror) {

UIImage *image = [UIImage imageNamed:@"prod_img3.png"];
pro_image.image = image;
}
else{
UIImage *image = [UIImage imageWithData:imageData];
pro_image.image = image;
}
}
[self doneChecking];
});
});

关于iphone - 推送 View Controller 时应用程序崩溃,[NSConcreteData initWithContentsOfURL :options:error:]: nil URL argument',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18733345/

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