使用PFQueryTableViewController查询附近的用户

时间:2014-01-27 05:50:49

标签: ios objective-c tableview parse-platform

所以我正在尝试实现查询并返回当前用户附近的用户的PFQueryTableViewController。然而,当我在手机上同时运行它时,在我的模拟器上,我无法返回表格内的任何内容。我的班级与tableView中的storyboard相关联。有没有人有任何想法为什么这不起作用?以下是PFQueryTableViewController函数的大部分代码。

- (id) initWithCoder:(NSCoder *)aDecoder {

    self = [super initWithCoder:aDecoder];
    if (self) {

        self.className = @"User";
        self.keyToDisplay = @"name";
        self.pullToRefreshEnabled = YES;
       // self.paginationEnabled = YES;
    }

    return self;

}

- (PFQuery *) queryForTable {
    PFQuery *locals = [PFQuery queryWithClassName:self.className];

    if ([self.objects count] == 0) {
        locals.cachePolicy = kPFCachePolicyCacheThenNetwork;
    }
    TSAAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
    CLLocation *currentLocation = appDelegate.currentLocation;

    PFGeoPoint *point = [PFGeoPoint geoPointWithLatitude:currentLocation.coordinate.latitude longitude:currentLocation.coordinate.longitude];

    [locals whereKey:@"location" nearGeoPoint:point withinKilometers:0.1],
    [locals includeKey:@"name"];
    [locals includeKey:@"file"];

    return locals;
}
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object{



    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];}

    cell.textLabel.text = [object objectForKey:@"name"];
    if ([object objectForKey:@"file"] == nil) {
        cell.imageView.image = [UIImage imageNamed:@"profile_default"];
    }
    else {
        cell.imageView.image = [object objectForKey:@"file"];
    }

    return cell;

}

0 个答案:

没有答案
相关问题