1

我收到“此查询具有出色的网络连接。”

我知道一次只允许一个查询,我认为这就是我在这里所做的,但显然不是..

retrieveFromParse 位于 viewDidLoad。

-(void) retrieveFromParse{

    PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];
    [query whereKey:@"photo" equalTo:[PFObject objectWithoutDataWithClassName:@"photoObject" objectId:self.currentObjectID]];
    [query orderByDescending:@"createdAt"];

    [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
        if (!error) {
        // The find succeeded.
            NSLog(@"Successfully retrieved %d scores.", (int)objects.count);
            // Do something with the found objects
            for (PFObject *object in objects) {
                NSLog(@"%@", object.objectId);

                self.commentArray = [object objectForKey:@"comment"];
            }
        } else {
            // Log details of the failure
            NSLog(@"Error: %@ %@", error, [error userInfo]);
        }
    }];

    // 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;
    }
}


- (id)initWithStyle:(UITableViewStyle)style currentObjectID:(NSString*) currentObjectID {
    self = [super initWithStyle:style];
    if (self) {

        self.currentObjectID = currentObjectID;

        self.parseClassName = @"extra";
        self.pullToRefreshEnabled = YES;
        self.paginationEnabled = NO;
        self.objectsPerPage = 25;

    }
    return self;
}
4

1 回答 1

0

问题在这里:

if ([self.objects count] == 0) {
    query.cachePolicy = kPFCachePolicyCacheThenNetwork;
}

在后台拨打电话,您正在拨打该电话。换句话说,您正在尝试修改query当前正在制作的 a,而它正在后台制作 - 触发错误。试试这个:

-(void) retrieveFromParse{

    PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];
    [query whereKey:@"photo" equalTo:[PFObject objectWithoutDataWithClassName:@"photoObject" objectId:self.currentObjectID]];
    [query orderByDescending:@"createdAt"];

    [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
        if (!error) {
        // The find succeeded.
            NSLog(@"Successfully retrieved %d scores.", (int)objects.count);
            // Do something with the found objects
            for (PFObject *object in objects) {
                NSLog(@"%@", object.objectId);

                self.commentArray = [object objectForKey:@"comment"];
            }
        } else {
            // Log details of the failure
            NSLog(@"Error: %@ %@", error, [error userInfo]);
        }

        // 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;
        }
    }];
}
于 2015-08-13T15:09:38.717 回答