首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PFObject救不了PFFile PArse

PFObject救不了PFFile PArse
EN

Stack Overflow用户
提问于 2014-08-07 16:35:10
回答 2查看 853关注 0票数 0

在object中,我似乎不能将Pffile对象设置为Pfobject键的值。我正在试图将NSData从AVAudioPlayer中保存到PFfile中。如果我这样做:

代码语言:javascript
复制
NSData * audioData=[self.shoutInfoArray objectAtIndex:1];
PFFile * audiofile=[PFFile fileWithName:@"shoutData" data:audioData];
bool saved=[audiofile save]; //This bool is positive, so it does save!?
[shout fetchIfNeeded];
shout[@"audioData"]=audiofile; //BUGGY LINE

我得到以下错误:

错误:键audioData的无效类型,预期字节,但已获得文件(代码: 111,版本: 1.2.20)

找不到原因?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-03-02 08:52:14

清除你的数据库。我是说drop列audioData。它缝上了一些类型的错误。

票数 0
EN

Stack Overflow用户

发布于 2014-08-07 16:50:34

要将PFFile对象保存为PFObject的一部分:还请检查文件大小不应大于10 be。

代码语言:javascript
复制
PFFile * audiofile=[PFFile fileWithName:@"shoutData.aif" data:audioData];

[imageFile saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {

 //Use async call.
 // It is compulsory to save the PFFile object first and then used it with PFObject

  if(succeeded)
  {
    PFObject *shout = [PFObject objectWithClassName:@"UserData"];
    shout[@"audioData"] = audiofile;
    [shout saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {

        if(error)
        {
            NSLog(@"error %@",error.localizedDescription);

        }
        else
        {
            if(succeeded)
            {
                NSLog(@"object save on parse");
            }
        }
    }];
  }

}];
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25187747

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档