0

エラーが発生しています

キャッチされていない例外 'NSInvalidArgumentException' が原因でアプリを終了しています。理由: '-[NSConcreteData initWithContentsOfURL:options:error:]: nil URL argument'`

viewControllerからプッシュしようとするとアプリがクラッシュViewControllerAする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];
    });
});

私は何を間違っていますか?助けてくれてありがとう。

4

1 に答える 1

1
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];
    });
});
于 2013-09-11T05:49:16.160 に答える