2014-11-03 21 views
-2

任何想法爲什麼我的代碼會崩潰?我正在將NSMutableArray轉換爲NSString,並使用該字符串獲取我的UIImageView的網址。崩潰在NSURL線。NSMutableArray到NSString到UIImageView代碼破解

NSString *imgstring = [imageOne componentsJoinedByString:@""]; 

NSURL *imageURL = [NSURL URLWithString:imgstring]; 

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ 
    NSData *imageData = [NSData dataWithContentsOfURL:imageURL]; 

    dispatch_async(dispatch_get_main_queue(), ^{ 
     // Update the UI 
     self.imageview.image = [UIImage imageWithData:imageData]; 
    }); 
}); 
+3

從崩潰中發佈堆棧跟蹤。 – Dex 2014-11-03 03:54:39

+2

至少應包含* exact *和* complete *異常消息以及異常堆棧跟蹤以及相關代碼。 – 2014-11-03 04:03:04

+0

https://www.dropbox.com/s/mg9ub3xlj2j5afx/Screen%20Shot%202014-11-02%20at%2011.03.35%20PM.png?dl=0 – user2868511 2014-11-03 04:05:26

回答

0

從Apple文檔,

URLString:URL字符串用來初始化的NSURL對象。必須是符合RFC 2396的URL。此方法根據RFC 1738和1808解析URLString。

在OS X v10.7及更高版本或iOS 5及更高版本中,如果URL字符串爲零,則此方法返回nil。在早期版本中,如果URL字符串爲零,則此方法會引發異常。

+0

它是零。我該如何解決? https://www.dropbox.com/s/mg9ub3xlj2j5afx/Screen%20Shot%202014-11-02%20at%2011.03.35%20PM.png?dl=0 – user2868511 2014-11-03 04:08:04