2012-03-10 10 views
0

私のiPhoneにXcode経由で配備されたときに正常に動作するように見えますが、アプリケーションストアにダウンロードされるとクラッシュします。それは、それが決してレビューを通過しなかったように、これはAppleのために働いたに違いないでしょうか?Xcodeから配備された場合、App StoreからのALAssetLibraryエラーは

私は他の携帯電話を試しましたが、クラッシュします。クラッシュログを見ると、以下のコードが気になる領域です。

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ 
    // Do a tasks in the background 
    library = [[ALAssetsLibrary alloc] init]; 

    NSMutableArray *itemFileName = [[NSMutableArray alloc] init]; 

    for (Item *it in tag.Items) { 
     [itemFileName addObject:it.name]; 
    } 

    void (^assetEnumerator)(ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *asset, NSUInteger index, BOOL *stop) { 
     if(asset != NULL && [asset valueForProperty:ALAssetPropertyType] == ALAssetTypePhoto) { 

      ALAssetRepresentation *rep = [asset defaultRepresentation]; 
      NSString *fileName = [rep filename]; 



      if ([itemFileName containsObject:fileName]) { 
       AssetView *assetView = [[AssetView alloc] initWithAsset:asset]; 
       assetView.delegate = self; 
       assetView.fileName = fileName; 
       //assetView.index = counter; 
       [self.assetViews addObject:assetView]; 
       //NSLog(@"%i",index); 

      } 

     } 
    }; 

    void (^assetGroupEnumerator)(ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop) { 
     if(group != nil) { 
      [group enumerateAssetsUsingBlock:assetEnumerator]; 
     } 
     else{ 
      //[self performSelectorOnMainThread:@selector(reloadTableView) withObject:nil waitUntilDone:YES]; 
      // Hide the HUD in the main tread 
      dispatch_async(dispatch_get_main_queue(), ^{ 
       [self reloadTableView]; 
       [MBProgressHUD hideHUDForView:self.navigationController.view animated:YES]; 
       [self loadImageTags]; 

       if([self.assetViews count] != [tag.Items count]){ 
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Info" 
                    message:@"Some items have been deleted from the device. If none remain for this tag it will be deleted." 
                    delegate:self 
                  cancelButtonTitle:nil 
                  otherButtonTitles: @"OK", nil]; 
        [alert show]; 

        MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES]; 
        hud.labelText = @"Cleaning..."; 

        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ 
         [self clearupOrphanedItems]; 

         dispatch_async(dispatch_get_main_queue(), ^{ 
          [MBProgressHUD hideHUDForView:self.navigationController.view animated:YES]; 
         }); 

        }); 
       }     
      }); 
     } 
    }; 

    // Group Enumerator Failure Block 
    void (^assetGroupEnumberatorFailure)(NSError *) = ^(NSError *error) { 

     UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Error" message:[NSString stringWithFormat:@"Album Error: %@ - %@", [error localizedDescription], [error localizedRecoverySuggestion]] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; 
     [alert show]; 

     NSLog(@"A problem occured %@", [error description]);          
    }; 

    // Enumerate Albums 
    [library enumerateGroupsWithTypes:ALAssetsGroupAll 
          usingBlock:assetGroupEnumerator 
         failureBlock:assetGroupEnumberatorFailure]; //HERE IS WHERE IT DIES!!!  

}); 

私はどちらかそれが道にデバッグ時に正常に動作あるいは単に場合のXcodeを経由して携帯電話に展開して問題がブロック内ALAssetLibraryのインスタンス化とに起因しているかどうかわからないのです

誰でも当てることができますいくつかのこれは私のために光?

答えて

0

コアダータおよびスレッディングの問題を回避するには、 を確認してください。1)アプリケーションのライフサイクル全体で1つのalassetslibraryインスタンスを作成すること。したがって、資産ライブラリインスタンスをappdelegateまたはdispatch_onceのいずれかで初期化することをお勧めします。 2)メインスレッドにalassetslibraryインスタンスを作成してください。

乾杯、

ヘンドリック

関連する問題