在发送消息(即在Firebase对象上调用setValue)之前,是否有建议的方法来确定用户是在线还是离线?
例如:
[firebase setValue:someValue withCompletionBlock:^(NSError *error, Firebase *ref) {
// This block is ONLY executed if the write actually completes. But what if the user was offline when this was attempted?
// It would be nicer if the block is *always* executed, and error tells us if the write failed due to network issues.
}];
Run Code Online (Sandbox Code Playgroud)
我们在iOS应用程序中需要这个,因为如果用户进入隧道,用户可能会失去连接.如果Firebase没有提供内置的方法,我们只需要监控iOS的Reachability API.
我有一个使用PyCharm管理的Python/Django项目.在Mac OSX Yosemite下,一切都运行良好.今天早上我升级到El Capitan的最终版本,现在我无法运行该项目.我得到的错误是:
加载MySQLdb模块时出错:没有名为MySQLdb的模块
我已经尝试了过去问题的所有建议,但没有人解决它.最常见的建议似乎是:
sudo pip安装MySQL-python
当我这样做时,我得到:
要求已经满足(使用--upgrade升级):MySQL-python in /Library/Python/2.7/site-packages
其他建议都没有帮助.我可以尝试重新安装MySQL,但我认为这不是MySQL的破坏.这可能与权限有关.任何人都可以帮助我再次去吗?
在后台异步保存对象时,我得到RLMException:'无法添加来自不同Realm的对象'.但是,如果删除异步代码,相同的保存工作正常.
该对象与现有对象有关系.例如:
class Person: Object {
name: String
school: School
}
class School: Object {
name: String
}
let person = new Person()
person.name = "John"
person.school = school // Existing object selected from a dropdown.
DispatchQueue.global().async {
do {
let realm = try Realm!
try realm.write {
realm.add(person, update: true)
}
DispatchQueue.main.async {
// Success!
}
} catch let error as NSError {
DispatchQueue.main.async {
// Error!
}
}
}
Run Code Online (Sandbox Code Playgroud)
此代码导致崩溃.但是,如果我删除DispatchQueye.global().async,一切正常.我遇到了一些线程问题吗?
注意:该school对象是预先存在的,并从Results<School>集合中选择.