2017-01-26 7 views
-1

次のエラーが発生しました。どこにあるのかわかりません。問題を見つけるのを手伝ってください。キャッチされない例外により 'NSInvalidArgumentException'、理由にアプリを終了TIA- [__ NSArrayM length]:インスタンスに送信された認識できないセレクタ0x145ecca0

: ' - [__ NSArrayM長]:認識されていないセレクタはインスタンス0x145ecca0に送られた' ***まずスローコールスタック:

- (void)viewDidLoad 
    { 
     [super viewDidLoad]; 
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero]; 
     label.backgroundColor = [UIColor clearColor]; 
     label.font = [UIFont fontWithName:@"Helvetica neue" size:20.0]; 
     //label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5]; 
     //label.textAlignment = UITextAlignmentCenter; 
     label.textColor = [UIColor whiteColor]; // change this color 
     self.navigationItem.titleView = label; 
     label.text = @"My Details"; 
     [label sizeToFit]; 
    } 

    #pragma mark - 
    #pragma mark Table view data source 

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
     // Return the number of sections. 
     return 1; 
    } 


    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
     // Return the number of rows in the section. 

     return 30; 
    } 


    // Customize the appearance of table view cells. 
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 


     static NSString *CellIdentifier = @"Cell"; 
     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
     if (cell == nil) 
     { 

      cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; 
      cell.textLabel.font=[UIFont fontWithName:@"Helvetica neue" size:14.0]; 
      cell.detailTextLabel.font=[UIFont fontWithName:@"Helvetica neue" size:13.0]; 
      cell.textLabel.textColor=[UIColor colorWithRed:199.0/255.0 green:65.0/255.0 blue:69.0/255.0 alpha:1.0]; 
      cell.selectionStyle = UITableViewCellSelectionStyleGray; 
     } 

     NSArray *keys = [myDict allKeys]; 

     for(int i=0 ; i<[keys count]; i++) 
     { 

      NSString *value=[myDict objectForKey:[keys objectAtIndex:i]]; 
      if ([value isEqual: [NSNull null]]||[value length]==0) { 

       [myDict setValue:@"--" forKey:[keys objectAtIndex:i]]; 

      } 

     } 

     if(indexPath.row==0) 
     { 
      cell.textLabel.text = @"Relationship"; 
      cell.detailTextLabel.text=[myDict objectForKey:@"Relationship"]; 
     } 

     if(indexPath.row==1) 
     { 
      cell.textLabel.text = @"Person Name"; 
      cell.detailTextLabel.text=[myDict objectForKey:@"PersonName"]; 
     } 

     if(indexPath.row==2) 
     { 
      cell.textLabel.text = @"Shopping"; 
      cell.detailTextLabel.text=[myDict objectForKey:@"shopping"]; 
     } 
     if(indexPath.row==3) 
     { 
      cell.textLabel.text = @"Quantity"; 
      cell.detailTextLabel.text=[myDict objectForKey:@"Quantity"]; 
     } 
     if(indexPath.row==4) 
     { 
      cell.textLabel.text = @"Pants"; 
      cell.detailTextLabel.text=[myDict objectForKey:@"pants"]; 
     } 
     if(indexPath.row==5) 
     { 
      cell.textLabel.text = @"Shirts"; 
      cell.detailTextLabel.text=[myDict objectForKey:@"shirts"]; 
     } 
     if(indexPath.row==6) 
     { 

      cell.textLabel.text = @"Other"; 
      cell.detailTextLabel.text=[myDict objectForKey:@"other"]; 
     } 
     if(indexPath.row==7) 
     { 
      cell.textLabel.text = @"Start Date"; 
      NSString *str=[myDict objectForKey:@"startDate"]; 
      NSString *str2= [str substringToIndex:10]; 
      cell.detailTextLabel.text=str2; 
     } 
     if(indexPath.row==8) 
     { 
      cell.textLabel.text = @"End Date"; 
      NSString *str=[myDict objectForKey:@"endDate"]; 
      NSString *str2= [str substringToIndex:10]; 
      cell.detailTextLabel.text=str2; 
     } 
     if(indexPath.row==9) 
     { 
      cell.textLabel.text = @"Address"; 
      cell.detailTextLabel.text=[myDict objectForKey:@"address"]; 
     } 
     if(indexPath.row==10) 
     { 
      cell.textLabel.text = @"Notes"; 
      cell.detailTextLabel.text=[myDict objectForKey:@"Notes"]; 
     } 
     if(indexPath.row==11) 
     { 
      cell.textLabel.text = @"Bill"; 
      cell.detailTextLabel.text=[myDict objectForKey:@"bill"]; 
     } 
     if(indexPath.row==12) 
     { 
      cell.textLabel.text = @"Grand Total"; 


      cell.detailTextLabel.text=[myDict objectForKey:@"total"]; 

     } 
     if(indexPath.row==13) 
     { 
      cell.textLabel.text = @"Signature"; 
      cell.detailTextLabel.text=[myDict objectForKey:@"sign"]; 
     } 

     return cell; 
    } 
+0

問題を除いて、データソースおよび/またはスタティックセルとしてアレイを使用することを検討してください。 – vadian

答えて

2

NSArrayはしないでくださいlengthに応答しますが、countに応答します。
おそらくvalueにありますが、NSStringと予想されますが、代わりに配列があります。
値を設定する際に何か問題があります。

0

この:

[myDict objectForKey:[keys objectAtIndex:i]]; 

NSStringNSArrayがない戻っています。

1

あなたは別のものを期待しているかもしれませんし、それは他のタイプの値を持っているかもしれません。あなたはNSStringを期待しているかもしれません。 Youcは、idデータ型を使用することができます。これは私のために解決されました。

関連する問題