2013-09-17 5 views
0

Итак, я пытаюсь изменить свой массив, который я создал с помощью PFQuery (parse.com). Мне нужно, чтобы проверить его, а затем удалить объекты из него, а затем отобразить его в UITableView, но когда я запускаю его, я получаю эту ошибкуNSArrayM objectAtIndex:]: index 2 за пределами границ [0 .. 1] '

- (PFQuery *)queryForParse 
{ 
    PFQuery *query1 = [PFQuery queryWithClassName:self.parseClassName]; 

    //[query1 selectKeys: [NSArray arrayWithContentsOfFile:[ NSString @"checkMark"]]]; 

    [query1 whereKey:@"location" nearGeoPoint:[PFGeoPoint geoPointWithLatitude:[LocationController sharedSingleton].locationManager.location.coordinate.latitude longitude:[LocationController sharedSingleton].locationManager.location.coordinate.longitude] withinMiles:50]; 
    [query1 findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { 
     if (!error){ 

      placesArray = [[NSMutableArray alloc] initWithArray:objects]; 
      NSMutableArray *toDelete = [NSMutableArray array]; 

      for (PFObject *tempObject in placesArray){ 
       if ([tempObject objectForKey:@"checkMark"] == nil){ 
        [toDelete addObject:tempObject]; 
       } 
      } 
      [placesArray removeObjectsInArray:toDelete]; 
      NSLog(@"%@", placesArray); 
     } 
     [placesTable reloadData]; 
    }]; 
    return query1; 
} 


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"Cell"; 
    PlacesTableCell *cell = (PlacesTableCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil){ 
     cell = [[PlacesTableCell alloc] init]; 
    } 

    PFObject *tempObject = [placesArray objectAtIndex:indexPath.row]; 
    cell.message.text = [tempObject objectForKey:@"message"]; 

    return cell; 
} 
+0

что делает ваш "' 'numberOfRowsInSection:" метод выглядеть? –

+0

У меня нет одного – david2391

+0

Я довольно новичок в Objective C, поэтому я все еще пытаюсь понять все. – david2391

ответ

0

Похоже, вы можете просто нужно добавить, что «numberOfRowsInSection:» метод, то ,

Например:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    // assuming only one section and one table here 
    return([placesArray count]); 
} 
+0

СПАСИБО! Я отрывал волосы от этого хаха – david2391

Смежные вопросы