- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个具有数组键的 PFObject
。我可以在此 PFObject
上成功调用 addObject:
,并且可以使用 NSLog
确认该对象已正确添加到数组键中。然而,当我尝试将 PFObject
保存到 Parse 时,尽管它说一切都成功了,但数据浏览器中没有显示更改。
我已经尝试了一切,甚至可以让它在我的应用程序的旧版本中工作,但由于某种原因它不再工作了。
我发布了另一个关于这个 here 的 StackOverflow 问题
我得到的唯一回应是一些评论说我应该触发“保存前”功能并通过 Cloud Code 记录所有内容。问题是我不懂 javascript,我一直在摆弄 Cloud Code 但什么也没发生。
这是我在我的应用程序中执行的代码:
[self.message addObject:currentUsersObjectId forKey:@"myArrayKey"];
然后我使用 saveInBackgroundWithBlock:
我需要更改 Cloud Code,以便它在保存和记录结果之前检查 self.message
对象的 "myArrayKey"
。
编辑 2:
这是我创建 currentUsersObjectId 的方式:
NSString *currentUsersObjectId = [[NSString alloc]init];
PFUser *user = [PFUser currentUser];
currentUsersObjectId = user.objectId;
编辑 3:
这是保存 block
[self.message saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (error) {
NSLog(@"An error has occurred.");
}
}];
编辑 4:
添加 Timothy 的云代码后,saveInBackgroundWithBlock:
现在没有成功完成。相反,会发生错误,并且错误对象 NSLogs 为“错误:未捕获试图用指向新的未保存对象的指针保存对象。(代码:141,版本:1.2.17)”以及:
Error Domain=Parse Code=141 "The operation couldn’t be completed. (Parse error 141.)" UserInfo=0x15dc4550 {code=141, error=Uncaught Tried to save an object with a pointer to a new, unsaved object.} {
code = 141;
error = "Uncaught Tried to save an object with a pointer to a new, unsaved object.";
}
这是我添加 Timothy 代码后的完整 Cloud Code 文件:
Parse.Cloud.define('editUser', function(request, response) {
var userId = request.params.userId;
//newColText = request.params.newColText;
var User = Parse.Object.extend('_User'),
user = new User({ objectId: userId });
var currentUser = request.user;
var relation = user.relation("friendsRelation");
relation.add(currentUser);
Parse.Cloud.useMasterKey();
user.save().then(function(user) {
response.success(user);
}, function(error) {
response.error(error)
});
});
Parse.Cloud.beforeSave("Messages", function(request, response) {
var message = request.object;
// output just the ID so we can check it in the Data Browser
console.log("Saving message with ID:", message.id);
// output the whole object so we can see all the details including "didRespond"
console.log(message);
response.success();
});
// log the after-save too, to confirm it was saved
Parse.Cloud.afterSave("Messages", function(request, response) {
var message = request.object;
// output just the ID so we can check it in the Data Browser
console.log("Saved message with ID:", message.id);
// output the whole object so we can see all the details including "didRespond"
console.log(message);
response.success();
});
最佳答案
来回反复之后,我很困惑为什么这对您不起作用。至于登录 Cloud Code,如果您按照添加代码指南进行操作,则可以将以下内容添加到您的 main.js 并进行部署:
Parse.Cloud.beforeSave("Messages", function(request, response) {
var message = request.object;
// output just the ID so we can check it in the Data Browser
console.log("Saving message with ID:", message.id);
// output the whole object so we can see all the details including "didRespond"
console.log(message);
response.success();
});
// log the after-save too, to confirm it was saved
Parse.Cloud.afterSave("Messages", function(request, response) {
var message = request.object;
// output just the ID so we can check it in the Data Browser
console.log("Saved message with ID:", message.id);
// output the whole object so we can see all the details including "didRespond"
console.log(message);
response.success();
});
有了这些,您就有了大量可以检查的服务器端日志记录。
关于javascript - 在 iOS 应用程序中更新 PFObject 的 key 时,需要在从 Parse Cloud Code 保存和登录时运行代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24748104/
[X-Post from parse.com] Person是 PFObject 的子类 . Address也是 PFObject 的子类 . Address有一个 @property类型 Perso
我在 Parse(在 iOS 上)中的当前用户返回正常,它拥有的属性之一是指向 PFObject“A”的指针。因此,当我获得当前用户时,我可以在当前用户中看到指向“A”的有效指针。 我不知道如何从那里
我正在尝试创建一个可以删除以下项目的函数: var array = [23,36,12,45,52,63] removeItem(12,array) result : array = [23,36,4
所以我正在设置这个应用程序,用户可以看到他们的位置,也可以看到其他人的位置。对于脚本,我正在关注这个问题。 how to retrive location from a PFGeopoint - (P
我正在使用 PFObject 子类化,例如: @interface CarObject : PFObject @property (nonatomic, strong) BrandObject *b
我只是想知道最简单/建议的方法是删除 PFObject 及其相关的所有内容。例如,在照片分享应用中,如果上传者想删除他/她发布的照片,您如何同时删除与该照片相关的所有“赞”和评论? 现在,我正在使
假设我有一组“myObject”类的PFObjects(本质上是字典)。此类的对象包含字典键“myDictionary”。反过来,“myDictionary”有一个键“myKey”,我想访问它并搜索与
我在 Xcode 中出现一个错误,提示“Downcast from '[PFObject]?'” '[PFObject]' 只解包可选值;您是要使用“!”吗? var iDArray = [S
Xcode 6.3.1:错误:无法将“PFObject”类型的值分配给“PFObject!”的值 试图理解更严格的 Swift '!'和 '?'要求,因为我认为这是错误的主要原因。 问题出在下面的代码
我正在将解析查询保存到数组中,但在 if letobjects=objectsas? 上出现以下错误? [PF对象] 并且出现以下错误:从“[PFObject]?”向下转型?到“[PFObject]”
我有一个名为 FriendRelation 的 Parse 类。这个类(class)有两个用户,一个是 friend ,另一个是用户。 我想获取用户的所有 friend 发布的所有消息。我尝试使用以下
然后我尝试将键从 PFObject 转换为字符串,但出现错误。我在 Parses 网站上找不到任何内容。请帮忙 var findProgram = PFQuery(className: "Progra
在我的应用程序中,当我尝试注册时,PFObjects 未保存在后台(emailLabel、FirstNameLabel、LastNameLabel、PasswordLabel。知道为什么吗 这是一个代
我已将 userIds 保存在解析为 String 的列中,并且我想将其转换为 PFObject 。我怎样才能快速做到这一点?我试图按如下方式检索 userId: followedUserQuery.
我有一个计时器,可以将当前日期倒计时到我在 Parse 中设置的日期(类名:“Date”)。现在,它使用我设置的 ObjectId 检索该数据。我想将其设置为使用“updatedAt”列中的日期来调用
我已经查看了所有内容,人们说使用 whereKey: equalTo: 可以在数组中工作,但由于某种原因它不适合我。我试图让用户搜索标签,并且包含该标签的所有帖子都会出现。当我删除 whereKey:
我有一个PFObject,Account,其中包含一个User数组,它们是PFUsers的子类。然后,User 有一个 NSDictonary 属性 allowableApps,它是一个 NSDict
我使用 Parse 作为我的后端,我试图让两个子类映射到同一个表。 在我的模型中,我有一个抽象的 Post 类,它符合 PFSubclassing 协议(protocol)并包含几个属性和方法。在我的
我想将来自 Parse 查询的 PFObjects 保存在我的类称为 listdata 的 NSMutableArray 中。我稍后会使用 listdata 数组。当我跟踪我的代码时,它会为找到的每个
我在使用 key 成功检索 PFObject 时遇到问题。对象最后为零: var object = PFObject(className:"Topic") var query = PF
我是一名优秀的程序员,十分优秀!