【发布时间】:2015-11-28 01:48:30
【问题描述】:
我正在使用适用于 iOS 的 Firebase SDK (2.4.2)。以下代码是SLComposeServiceViewController 对象中使用的didSelectPost() 函数的一部分。非常重要的一点是要指出这种行为在普通的UIViewController 中使用时是不一样的(我知道很奇怪)。
假设基本代码如下:
override func presentationAnimationDidFinish() {
// Retrieving content and identifying type here
}
override func didSelectPost() {
self.myRootRef.runTransactionBlock({
(currentData:FMutableData!) in
currentData.value = "test"
// Finalizing the transaction
return FTransactionResult.successWithValue(currentData)
}
)
self.extensionContext!.completeRequestReturningItems([], completionHandler: nil)
}
事务完成后,node_value 将从 Firebase 中完全消失。该值未设置,节点被删除。这是一个非常奇怪和意想不到的行为!
另一方面,以下代码按预期工作。
override func didSelectPost() {
self.myRootRef.setValue("test", withCompletionBlock: {
(error:NSError?, ref:Firebase!) in
if (error != nil) {
print("Data could not be saved.")
} else {
print("Data saved successfully!")
}
})
self.extensionContext!.completeRequestReturningItems([], completionHandler: nil)
}
几天前还没有这个问题,最后我运行了上面的代码。关于问题所在的任何见解?
【问题讨论】:
-
如果我的回答对您有用,请告诉我。如果是,请将其标记为已接受。保持未回答的队列清晰是件好事。
-
@DavidEast 我还没有时间测试答案。这个周末我很可能会这样做,之后我会在这里确认答案。
标签: ios swift debugging firebase