2014-11-25 3 views
0

알림 배열을 채우기 위해 아래 코드가 있습니다. 이 배열은 iOS 앱의 메뉴에 알림을 채우기 위해 필요합니다.NSMutableArray를 채우십시오.

// extract specific value... 
NSArray *switchValues = [res objectForKey:@"data"]; 

NSLog(@"%@", switchValues); 

for (NSDictionary *switchValue in switchValues) { 

    NSString *text = [switchValue objectForKey:@"text"]; 

    NSLog(@"%@", text); 

    [self.notificationsArray addObject:text]; 

} 

또한 선 아래로 나는 다음을 수행하십시오

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *cellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier]; 

    if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier]; 
    } 

    NSMutableArray *titles = self.notificationsArray; 
    cell.textLabel.text = titles[indexPath.row]; 

    return cell; 
} 

을 그러나, 나는 하늘의 배열을 점점 계속. 내가 도대체 ​​뭘 잘못하고있는 겁니까?

+4

notificationsArray를 초기화했으며 switchValues ​​개수가 0보다 큰지 확인 했습니까? – Vig

+0

은 @Vig와 일치합니다. –

답변

0

[notificationsArray objectAtIndex:indexPath.row] 

대신

NSMutableArray *titles = self.notificationsArray; cell.textLabel.text = titles[indexPath.row]; 로하지 않는다?

당신이 정말로 원하는 해달라고하면, 적어도 NSMutableArray *titles = [NSMutableArray arrayWithArray:self.notificationsArray];

그리고 코드의 첫 번째 조각 , 콘솔 로그는 무엇입니까? for 루프를 입력 하시겠습니까?