【问题标题】:Automatic sync realm with server [closed]与服务器自动同步领域[关闭]
【发布时间】:2015-11-24 17:26:44
【问题描述】:

我正在使用带有一些 api 的领域,我想在我在服务器上删除对象时达到这种行为,它应该在应用程序上自动删除。 使用 CoreData 有一个 RestKit 框架可以解决问题,领域是否有类似的东西。我试过 ObjectMapper 和 Alamofire 都没有成功。

【问题讨论】:

    标签: ios swift restkit realm


    【解决方案1】:

    您需要自己处理对象删除。这可能如下所示:

    Alamofire.request(.DELETE, "http://localhost:3000/product/\(object.id).json")
             .response { request, response, data, error in
                 // TODO: Replace through appropriate error handling
                 precondition(error == nil, "An error occurred \(error!)")
                 let realm = try! Realm()
                 try! realm.write {
                     realm.delete(object)
                 }
             }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多