简体   繁体   English

iOS-Swift-比较2个实体的值

[英]iOS - Swift - Compare 2 entities for the values

I need to compare the values in one Entity another entity. 我需要比较一个实体中另一个实体的值。 I donot want to have the one on one string comparison. 我不想进行一对一的字符串比较。 As it has so many Params, and the values will be keep adding in future. 由于它具有许多参数,因此将来会不断增加这些值。 Do we have any simple solution for this? 我们对此有任何简单的解决方案吗?

Its not about Core Data. 它与核心数据无关。 Normal Custom Objects. 普通自定义对象。

For Ex: I need to compare to Employee Object for its values. 对于Ex:我需要将其值与Employee Object进行比较。

func compareTwoEntities() -> Bool
{
    let json = JSONSerializer.toJson(userEntity)

    let json2 = JSONSerializer.toJson(userBackUpEntity)


    if json == json2
    {
        return true
    }

    return false
}

You could try comparing two arrays made of these elements of entities. 您可以尝试比较由这些实体元素组成的两个数组。 Have you tried that? 你有尝试过吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM