首页 > 解决方案 > iOS Swift Parse Local Data Store unpin doesn't work when offline

问题描述

This is not a pointer object issue the unpin seems to only fail when device is offline (not connected to internet)

Query:

let query = PFQuery(className: "Test")
query.fromLocalDatastore()
query.findObjectsInBackground { (objects, error) in
   if let objects = objects {
      print(objects)
   }
}

Save:

let newTest = PFObject(className: "Test")
newTest["info"] = "Test"
newTest.pinInBackground()
newTest.saveEventually()

I tried saving while online and offline - I thought maybe I couldn't unpin it until it reaches the server however it doesn't unpin from local either way

Unpin / delete:

newTest.unpinInBackground()
newTest.deleteEventually()

I tried removing the delete eventually thinking maybe it had to stay pinned until it was successfully deleted from server however this too didn't change the results

When I call unpinInBackground in a block with a completion it returns as successfully unpinned however when I perform the local query the object still returns

I tried using the .unpin() with a try/catch - same results

When internet is restored and app is restarted all changes sync and both the local datastore and cloud database have the correct data

Is this the expected behavior? Is it not possible to unpin from local when offline?

When I run this code with the device connected to internet the whole time it works perfectly as expected

I am testing on the Simulator iOS 14.1 - xCode 112.1 - and have not yet tested on a physical device

I'm on Parse iOS SDK 19.0.0 - Parse Server 3.7.2

标签: ioslocal-storageofflinedelete-fileparse-server

解决方案


推荐阅读