2017-09-21 5 views
-1
if(counter>=keys.count){ 

     NSLog(@"finished"); 
     [_images removeFromSuperview]; 
     // [_alphabetsShowImageView removeFromSuperview]; 
     [_speakerOrMicImageView removeFromSuperview]; 
     UIImageView *congratzView = [[UIImageView alloc]initWithFrame:self.view.frame]; 
     congratzView.image = [UIImage imageNamed:@"congratulation.png"]; 
     [self.view addSubview:congratzView]; 

    } 

    else{ 


      arrVal = [dictAlpha objectForKey:keys[i]]; 


       if(j>=arrVal.count) 

        { 
         NSLog(@"finished"); 
         [_alphabetsShowImageView removeFromSuperview]; 
         [_speakerOrMicImageView removeFromSuperview]; 
         UIImageView *congratzView = [[UIImageView alloc]initWithFrame:self.view.frame]; 
         congratzView.image = [UIImage imageNamed:@"congratulation.png"]; 
         [self.view addSubview:congratzView]; 
         // [self performSelector:@selector(navNew) withObject:nil afterDelay:3]; 

        } 
        else 
        { 
         [commonFunctionObject textToSpeechAction:arrVal :j :_alphabetsShowImageView :_speakerOrMicImageView :isMicPresent]; 
         [NSTimer scheduledTimerWithTimeInterval:10.0 target:self selector:@selector(ActionToCkeckRecordCompletion) userInfo:nil repeats:YES]; 
        } 





      } 








} 

出力のインデックスが範囲を越えて2 [0 .. 1] = arrval.count then else条件に.orを入力し、if条件ループに入る。 カウンタ> = keys.count場合 は、それはあなたが反復するcounterを使用しているが、あなたは別の変数と配列要素にアクセスしている文の条件__NSArrayI objectAtIndex:]:私はJ <そして 、それはif文の条件に入力する必要があります カウンタ< = keys.count をneed- Objective-Cの

答えて

0

場合に入力する必要があります。

あなたのエラーは、明らかにカウンタとアクセサの両方が、カウンタと等しいかどうかを示します。i & j

あなたのコードは、高速トラバーサルと呼ばれることが条件です。また、このシナリオの列挙を検討し、カウンターを維持するという苦痛から救うことができます。 if-else文を避けることもできます。 1つのコードをシンプルに保つのに役立ちます!

for(NSString* key in dictAlpha) { 
    arrVal= [dictAlpha objectForKey:key]; 
} 
関連する問題

 関連する問題