我正在尝试保存新的PFObject
并收到以下错误:
Error Domain = NSCocoaErrorDomain Code = 3840“JSON文本没有以数组或对象开头,并且选项允许未设置片段。” UserInfo = {NSDebugDescription = JSON文本不以数组或对象开头,并且选项允许未设置片段。}
据说这个错误是在Parse-SDK-IOS-OSX 1.9.1发布时修复的。但我最近更新了最新的SDK和解析服务器并继续收到错误。
我有三个案例:
后者是唯一引发错误的案例。
PFObject *new = [PFObject objectWithClassName:@"Moment"];
[new setObject:newUser forKey:@"user"];
[new setObject:[NSNumber numberWithBool:YES] forKey:@"profile"];
if ([dataObject sharedInstance].caption) [new setObject:[dataObject sharedInstance].caption forKey:@"caption"];
[new setObject:[dataObject sharedInstance].storyboard forKey:@"storyboard"];
if (largeVideo) {
NSLog(@"%@", [dataObject sharedInstance].splitArray);
for (int i = 0; i < [dataObject sharedInstance].splitArray.count; i++){
PFFile *file = [[dataObject sharedInstance].splitArray objectAtIndex:i];
if (i == 0) {
[new setObject:file forKey:@"video"];
}else{
[new setObject:file forKey:[NSString stringWithFormat:@"video%i", i]];
}
}
}else{
NSData *videoData = [[NSData alloc]initWithContentsOfURL:[dataObject sharedInstance].output];
PFFile *file = [PFFile fileWithData:videoData contentType:@"video/mp4"];
[new setObject:file forKey:@"video"];
}
[new setObject:fileF forKey:@"image"];
[new setObject:fileT forKey:@"thumbnail"];
[new saveInBackgroundWithBlock:^(BOOL succeded, NSError *error){
}];
保存照片和小视频都可以。
答案 0 :(得分:0)