所以我正在检索一个文件作为其中一个字段的对象。在Parse.com数据浏览器中,文件存在并下载。但是,当我检索对象时,PFFile *wordlistFile = [object objectForKey:kWSWordlistFilesFileKey];
返回null,因此getDataInBackgroundWithBlock
什么都不做。
这是我正在检索的对象的日志。没有对文件的引用:
2013-12-03 12:07:10.635 WSPhoto[24958:a0b] object = <WordlistFiles:lRHFmHaPRg:(null)> {
ACL = "<PFACL: 0xd445670>";
language = Spanish;
}
这是完整的代码。根据我见过的一些例子,我似乎正在做的一切:
PFQuery* wordlistFilesQuery = [PFQuery queryWithClassName:kWSWordlistFilesClassKey];
[wordlistFilesQuery whereKey:kWSWordlistFilesLanguageKey equalTo:language];
[wordlistFilesQuery includeKey:kWSWordlistFilesFileKey];
[wordlistFilesQuery setCachePolicy:kPFCachePolicyNetworkOnly];
[wordlistFilesQuery getFirstObjectInBackgroundWithBlock:^(PFObject *object, NSError *error) {
if (!error) {
PFFile *wordlistFile = [object objectForKey:kWSWordlistFilesFileKey];
NSLog(@"******* wordlistFile = %@",wordlistFile);
// Show HUD view
AppDelegate *appDel = (AppDelegate *)[[UIApplication sharedApplication]delegate];
[appDel showGlobalProgressHUDWithTitle:@"Loading wordlist. This may take a while."];
[wordlistFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
if (!error) {
// Super private stuff here
}
// The data didn't load
else {
NSLog(@"loadWordlistFromDBByFile -- wordlist does not exist, loading by querying");
[self loadWordlistFromDBByQuery:language];
}
} progressBlock:^(int percentDone) {
}];
}
// The object didn't load
else {
NSLog(@"loadWordlistFromDBByFile -- wordlist does not exist, loading by querying");
[self loadWordlistFromDBByQuery:language];
}
}];
答案 0 :(得分:0)
确保您的kWSWordlistFilesFileKey与Parse.com上数据浏览器上显示的列名完全相同。
因此,如果该列被称为“wordlistfile”,请确保:
kWSWordlistFilesFileKey = @"wordlistfile";
答案 1 :(得分:0)
好的,这是一个愚蠢的错误。我在Parse.com数据浏览器中重新加载了WordlistFiles类,文件消失了。不知道是怎么回事。我向你们发誓,我正盯着它。我重新上传,现在它正在检索,并且似乎没有任何奇怪的行为,它正在删除它。
操作员错误。