4
我通過HTTP獲取JSON數據,並希望用自定義的MKAnnotationView在MKMapView中顯示它們。所以直到這裏都沒問題。如何檢查Xcode資產目錄中是否存在圖像?
糟糕的是,REST服務可能會返回在我的.xcassets文件中沒有等效項的引腳類型。有沒有什麼辦法來檢查應用程序的資產目錄中的條目,並避免這樣的消息:
CUICatalog:無效的資產名稱提供:NonExistingImage或無效的比例係數:2.000000
當前的代碼示例:
NSString * imageName = @"NonExistingImage";
if (imageName != nil) {
// this line creates the above message
UIImage * image = [UIImage imageNamed:imageName];
// checking for image != nil, otherwise use default image
} else {
// default image
}
好問題。它可以歸結爲「如何檢查XCode資產目錄中是否存在圖像?」。 – tilo
謝謝。更正了標題;) – mvoelkl
有沒有任何理由擺脫這個信息?這看起來沒有害處,因爲無效的資產名稱只返回零,沒有例外。 – TAKeanice