以下是我上传文件的代码。当应用程序放在后台时会完全取消,所以有任何内置的PFFile函数可以解决这个问题,这将是最简单的解决方案。
PFFile * file = [PFFile fileWithName:filetoUpload data:data];
[file saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
//Something bad has ocurred
if (![self CheckConnection])
{
UIAlertView *errorAlertView = [[UIAlertView alloc] initWithTitle:@"Error" message:@"The Internet connection appears to be offline " delegate:self
cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[errorAlertView show];
[errorAlertView release];
[file cancel];
}
}