加载一些数据后,PFQueryTableViewController单元格崩溃

时间:2015-05-04 16:14:22

标签: ios iphone ios7

我正在使用PFQueryTableViewController来上传数据。一切正常,但加载50-60行后,应用程序崩溃,我收到此错误:" [NSNull rangeOfCharacterFromSet:]:无法识别的选择器发送到实例0x34a53830。"这是我的一段代码。

@implementation ScreenUsersViewController

- (id)initWithCoder:(NSCoder *)aCoder
{
self = [super initWithCoder:aCoder];
if (self) {
    // Custom the table

    // The className to query on
    self.parseClassName = @"_User";

    // The key of the PFObject to display in the label of the default cell style
    self.textKey = @"name";

    self.imageKey=@"profilePicture";

    // Whether the built-in pull-to-refresh is enabled
    self.pullToRefreshEnabled = YES;

    // Whether the built-in pagination is enabled
    self.paginationEnabled = YES;

    // The number of objects to show per page
    self.objectsPerPage = 10;
   }
return self;
 }

 - (void)viewDidLoad
 {
 [super viewDidLoad];
 [self loadObjects];
// Do any additional setup after loading the view.
 }

- (PFQuery *)queryForTable
 {
 PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];
 if ([self.objects count] == 0) {
  query.cachePolicy = kPFCachePolicyCacheThenNetwork;
  }
 [query orderByDescending:@"name"];
 return query;
  }

 - (UITableViewCell *)tableView:(UITableView *)tableView   cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object
  {
 static NSString *simpleTableIdentifier = @"UsersCell";

 UITableViewCell *cell = [tableView    dequeueReusableCellWithIdentifier:simpleTableIdentifier];
 if (cell == nil) {
    cell = [[UITableViewCell alloc]    initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
 }

// Configure the cell

PFFile *thumbnail = [object objectForKey:@"profilePicture"];
UILabel *nameLabel = (UILabel*) [cell viewWithTag:101];
UILabel *usedLabel = (UILabel*) [cell viewWithTag:102];
UILabel *namecountry=(UILabel*) [cell viewWithTag:103];
UILabel *namestatus=(UILabel*) [cell viewWithTag:104];
PFImageView *thumbnailImageView = (PFImageView*)[cell viewWithTag:100];


if (tableView == self.tableView)
{   
thumbnailImageView.image = [UIImage imageNamed:@"fb_profile_default.jpg"];

nameLabel.text = [object objectForKey:@"username"];

usedLabel.text = [object objectForKey:@"Label1"];

[namecountry setText:_country];

namestatus.text = [object objectForKey:@"Status"];

[thumbnail getDataInBackgroundWithBlock:^(NSData *data, NSError *error)   {
        thumbnailImageView.image =[UIImage imageWithData:data];
         }];

 }

else if(tableView == self.searchController.searchResultsTableView)
 {
    PFObject *searchedUser = [self.usersFilteredResult  objectAtIndex:indexPath.row];
    NSString *content = [searchedUser objectForKey:@"username"];

    nameLabel.text = content;
    thumbnailImageView.image = [UIImage imageNamed:@"fb_profile_default.jpg"];

    PFFile *thumbnail = [object objectForKey:@"profilePicture"];

    [thumbnail getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
        thumbnailImageView.image =[UIImage imageWithData:data];
    }];
    NSLog(@"Content: %@", content);  
}
return cell;
}

0 个答案:

没有答案