Unsyncing objects from query-based sync



I know how to delete objects from a Realm, but how do I delete objects locally from a query-based sync Realm? For example, lets say we partially sync all Person.filter(“areaCode = 420”). Restart app so the SyncSubscription instance is now gone. New SyncSubscription for Person.filter(“areaCode = 000”). When the subscription completes, fetch all Person and the results are both 420 and 000 area codes.

How can I make it so that only objects matching the 2nd query stay on the device? Obviously I can’t .unsubscribe() the earlier SyncSubscription.


Figured it out:

myRealm.subscription(named: String)?.unsubscribe()

unsubscribe() is crossed out in Xcode, could anyone shed light on that?


Is it crossed if the subscription is not optional?


Its fine now. Probably a little Xcode bug. Thanks.