2013-04-30 20 views
5

Bir diziye nsindexpath eklemeye çalışıyorum .. dizine başka bir indexpath eklemeyi denediğimde sadece bir indexpath ekleyebiliyorum .. hata ayıklayıcı yalnızca en yeni dizin yolunu gösterir.NSMutableArray içine çok sayıda NSIndexPath ekleme

for (int i = 0 ; i<[notificationArray count]; i++) 
     { 
      selectedSymptIndexPath = [NSIndexPath indexPathForRow:selectedSymptomIndex inSection:keyIndexNumber]; 
      selectedSympIPArray = [[NSMutableArray alloc]init]; 
      [selectedSympIPArray addObject:selectedSymptIndexPath]; 
     } 

i gösteren birden indexpaths yerine hala döngü için eklemenin yalnızca yeni indexPath [selectedSympIPArray addObject:selectedSymptIndexPath]; dışında koymak çalışsanız bile

cevap

8

:

bu deneyin. Tamamen yanlış. Hatanızı bulun.

Bu kodu kullanabilirsiniz ....

selectedSympIPArray = [NSMutableArray array]; 
for (int i = 0 ; i<[notificationArray count]; i++) 
     { 
      selectedSymptIndexPath = [NSIndexPath indexPathForRow:selectedSymptomIndex inSection:keyIndexNumber];    
      [selectedSympIPArray addObject:selectedSymptIndexPath]; 
     } 
12

Sen, ayırma döngü içinde her zaman dizisi init'ing olduğunu dont . Eğer yineleme her zaman ayırma, Kodunuzda

selectedSympIPArray = [[NSMutableArray alloc]init]; 

for (int i = 0 ; i<[notificationArray count]; i++) 
{ 
    selectedSymptIndexPath = [NSIndexPath indexPathForRow:selectedSymptomIndex inSection:keyIndexNumber]; 
    [selectedSympIPArray addObject:selectedSymptIndexPath]; 
} 
+0

@raptor sizin için çalışıyor? – satheeshwaran

+0

.. onun çalışma – raptor

+0

ama bazen UitableableView sanırım yanlış bir şekilde – raptor