magicalpanda / MagicalRecord

Super Awesome Easy Fetching for Core Data!
Other
10.8k stars 1.8k forks source link

MR_importFromObject(data: AnyObject) return the object which have merge with the existing one #1244

Open nucauthu opened 8 years ago

nucauthu commented 8 years ago

Hi team. Thank for your great work. I have a issues with creating object. Example, I have json:

{
name: "Test"
gender: 0
income: 30000
}

I use MR_importFromObject to create a NSManagedObject from json data

class func importFromJSON(json: JSON) -> User {
        let user = User.MR_importFromObject(json.dictionaryObject!)
        user.save()
        return user
    }

The problem is when the user profile change and refresh to get new data. The new json will be:

{
name: "Test A"
gender: 0
}

But the NSManagedObject return by the function above still contains the property of "income" with old value. It should be nil. It looks like that the function merge with existing object instead of create a new object and delete the exist object. Please help me to fix this. Thanks a lot.