I’m using a data-object relationship custom property in my table. When a user likes a song, I use the setProperty function to add that song to the likes column. And what displays there is the a list of the songs object Ids, separated by commas. I’m trying to find a way to unlike a song by removing a specific object ID from that list & keeping the others there. How do I do that?
I assume that you’re speaking about relation between “Users” and some custom table.
In order to remove a particular object from the list you should first retrieve the user with its related collection, then retrieve the collection from the user using “getProperty” method. Change the collection as you need and set it again to the user by setProperty method, and save user.
Yes Alexandr, that’s what I mean. But I’m struggling to get the collection using the get property because the collection is in the form of __NSArray which I don’t know how to store within a variable. I’ve tried to cast it to various types but it always terminates the app. Can you shed any light on this?
Hi Manenda,
You could investigate this doc section, in particular - Collections, Relations(Save/Update), Relation(Delete), Relations(Retrieve). There are Obj-C & Swift samples there. Hope it will be helpful for you.
Regards,
Slava