2015-02-23 49 views

回答

1

爲什麼不直接使用:

if ([userAlbums count]) { 
    //At least one item found. 
} 
else { 
    //Nothing found 
} 
2

您需要跟蹤userAlbums中的資產數量,並且如果直到最後一項資產被檢查時才找到資產,則返回未找到通知。

你可以不喜歡它:

NSString *localId   = /*local identifier of photo */; 
PHFetchResult *userAlbums = [PHAsset fetchAssetsWithLocalIdentifiers:@[localId] options:nil]; 
NSUInteger assetCount  = [userAlbums count]; 
__block NSUInteger assetCounter = 0; 
[userAlbums enumerateObjectsUsingBlock:^(PHAsset *asset, NSUInteger idx, BOOL *stop) 
{ 
     // Check whether you found the asset or not 
     if (/*asset found*/) 
     { 
      // Asset found, set the stop bool to yes 
     } 
     else if (assetCounter == assetCount) 
     { 
      //Data not found yet 
     } 
}];