为什么Parse.com加入表不起作用?

时间:2015-07-07 16:45:54

标签: ios uitableview parse-platform

我将此代码用于表视图:

@implementation FollowerTableViewController

- (instancetype)initWithStyle:(UITableViewStyle)style {
    self = [super initWithStyle:style];
    if (self) { // This table displays items in the Todo class
        self.parseClassName = @"FriendClass";
        self.pullToRefreshEnabled = YES;
        self.paginationEnabled = YES;
        self.objectsPerPage = 25;
    }
    return self;
}

- (PFQuery *)queryForTable {
    PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];
    [query whereKey:@"to" equalTo:[PFUser currentUser]];

    // If no objects are loaded in memory, we look to the cache first to fill the table
    // and then subsequently do a query against the network.
    if (self.objects.count == 0) {
        query.cachePolicy = kPFCachePolicyCacheThenNetwork;
    }

    [query orderByDescending:@"date"];

    return query;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath object:(PFObject *)object {

    static NSString *cellIdentifier = @"cell1";

    PFTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (!cell) {
        cell = [[PFTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
                                      reuseIdentifier:cellIdentifier];

    }

    // Configure the cell to show todo item with a priority at the bottom
    cell.textLabel.text = object[@"from"];

    NSLog(@"%@", object[@"from"]);
    //cell.detailTextLabel.text = [NSString stringWithFormat:@"Priority: %@",  object[@"priority"]];
    NSLog(@"%@ , %@", object[@"from"], object[@"to"]);


    return cell;
}
@end

这是我之前上传的:

-(void)follow {    
    // suppose we have a user we want to follow
    PFUser *otherUser = (PFUser *)textField.text;
    NSLog(@"%@", otherUser);    

    // create an entry in the Follow table
    PFObject *follows = [PFObject objectWithClassName:@"FriendClass"];
    [follows setObject:[PFUser currentUser]  forKey:@"from"];
    [follows setObject:otherUser forKey:@"to"];
    [follows setObject:[NSDate date] forKey:@"date"];
    [follows saveInBackground];
}

知道为什么它不起作用。

0 个答案:

没有答案