Deleting specific Object Realm Swift
<p>I've gone through Realm's documentation and I've looked online but didn't find any solution to my specific problem. </p>

<p>Here is what I have:</p>

<p>My app is storing specific information into various folders, the user can store the same Object in multiple folders or what so ever. </p>

<p>Here is the folder object, it has a one to many relations with items. Folders can store as many items as they want.</p>

<pre><code> class Folder: Object {

    dynamic var  name = ""
    dynamic var lastEdited = NSDate()
    dynamic var folderDescription = ""
    let items = List&lt;ItemModel&gt;()

}
</code></pre>

<p>The item model:</p>

<pre><code>class ItemModel: Object {

    dynamic var country:String!
    dynamic var date:String!
    dynamic var title:String!
    dynamic var area:String!
    dynamic var type:String!
    dynamic var text:String!
    dynamic var registered:String!
    dynamic var id:String!
    let metamap = List&lt;Meta&gt;()
    let authors = List&lt;Manu&gt;()
    let categories = List&lt;Category&gt;()

}
</code></pre>

<p>The user can store as many of these items in folders, they can add the same Item to multiple folders as well. For example the user can add the same item to the folder saved, bookmarks and wish list. </p>

<p>The problem I'm having is, when a user goes to delete an item from a folder, it deletes it from every other folder. E.g. I want to only delete a specific item from the saved folder, but for some reason it also deletes it from the bookmarks and wish list folder. </p>

<p>Here is what I am using to delete the folder:</p>

<pre><code>     let folderItemToDelete = folder?.items[indexPathToDelete!]
        try! uiRealm.write {
            uiRealm.delete(folderItemToDelete!)
        navigationController?.popViewControllerAnimated(true)

        }
</code></pre>

<p>I parse into a specific folder name and am trying to delete a folder at a specific index, but for some reason they all get deleted. What can I do so that it only deletes it from the specific folder? </p>