我正在'此查询具有出色的网络连接。'
我知道时间只允许一个查询,我认为这是我在这里所做的事情,但显然不是......
retrieveFromParse位于viewDidLoad。
08-13 21:11:21.898 1233-2167/? V/WindowManager﹕ Adding window Window{bd59a00 u0 com.cheatsheet.servercheck/com.cheatsheet.servercheck.MainActivity} at 2 of 6 (before Window{18c764e7 u0 Starting com.cheatsheet.servercheck})
08-13 21:11:21.904 2453-2468/? D/Http Connection﹕ failed to connect to /127.0.0.1 (port 80): connect failed: ECONNREFUSED (Connection refused)
08-13 21:11:21.945 2453-2469/? D/﹕ HostConnection::get() New Host Connection established 0xb43e0130, tid 2469
08-13 21:11:21.958 2453-2469/? I/OpenGLRenderer﹕ Initialized EGL, version 1.4
08-13 21:11:21.995 2453-2469/? D/OpenGLRenderer﹕ Enabling debug mode 0
08-13 21:11:22.015 2453-2469/? W/EGL_emulation﹕ eglSurfaceAttrib not implemented
08-13 21:11:22.015 2453-2469/? W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xb43cd940, error=EGL_SUCCESS
08-13 21:11:22.667 1233-1256/? I/ActivityManager﹕ Displayed com.cheatsheet.servercheck/.MainActivity: +950ms
答案 0 :(得分:0)
问题在于:
if ([self.objects count] == 0) {
query.cachePolicy = kPFCachePolicyCacheThenNetwork;
}
您在后台拨打电话后呼叫。换句话说,您正在尝试修改当前正在后台制作的query
- 触发错误。试试这个:
-(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;
}
}];
}