Как сравнить 2 словаря в Swift 3

Здравствуйте, я получаю дубликаты словарей из моего сервиса.

[{
DisplayName2 = "ABC";
Employee = "<null>";
EmployeeCode = 17227;
ImagePath = "/profile/image/759006c5e4214f0";
LeaveDetail = "<null>";
LeaveDetailLeaveDate = "2017-07-04T00:00:00";
LeaveEntry = "<null>";
LeaveEntryEndDate = "2017-07-04T00:00:00";
LeaveEntryNoOfDays = 1;
LeaveEntryStartDate = "2017-07-04T00:00:00";
LeaveEntryStartDateSession = FH;
LeaveType = "<null>";
LeaveTypeCode = 1;
LeaveTypeName = ANNUAL;
RequestStatus = C;
Shift = "<null>";
ShiftName = "";
SystemLeaveTypeCode = ANN;
TomorrowLeaveCount = 0;

},

{
DisplayName2 = "ABC";
Employee = "<null>";
EmployeeCode = 17227;
ImagePath = "/profile/image/759006c5e4214f0";
LeaveDetail = "<null>";
LeaveDetailLeaveDate = "2017-07-04T00:00:00";
LeaveEntry = "<null>";
LeaveEntryEndDate = "2017-07-04T00:00:00";
LeaveEntryNoOfDays = 1;
LeaveEntryStartDate = "2017-07-04T00:00:00";
LeaveEntryStartDateSession = FH;
LeaveType = "<null>";
LeaveTypeCode = 1;
LeaveTypeName = ANNUAL;
RequestStatus = C;
Shift = "<null>";
ShiftName = "";
SystemLeaveTypeCode = ANN;
TomorrowLeaveCount = 0;

},

{
DisplayName2 = "ABC";
Employee = "<null>";
EmployeeCode = 17227;
ImagePath = "/profile/image/759006c5e4214f0";
LeaveDetail = "<null>";
LeaveDetailLeaveDate = "2017-07-10T00:00:00";
LeaveEntry = "<null>";
LeaveEntryEndDate = "2017-07-10T00:00:00";
LeaveEntryNoOfDays = 1;
LeaveEntryStartDate = "2017-07-10T00:00:00";
LeaveEntryStartDateSession = FH;
LeaveType = "<null>";
LeaveTypeCode = 2;
LeaveTypeName = CASUAL;
RequestStatus = C;
Shift = "<null>";
ShiftName = "";
SystemLeaveTypeCode = CAS;
TomorrowLeaveCount = 0;

},

{
DisplayName2 = "ABC";
Employee = "<null>";
EmployeeCode = 17227;
ImagePath = "/profile/image/759006c5e4214f0";
LeaveDetail = "<null>";
LeaveDetailLeaveDate = "2017-07-10T00:00:00";
LeaveEntry = "<null>";
LeaveEntryEndDate = "2017-07-10T00:00:00";
LeaveEntryNoOfDays = 1;
LeaveEntryStartDate = "2017-07-10T00:00:00";
LeaveEntryStartDateSession = FH;
LeaveType = "<null>";
LeaveTypeCode = 2;
LeaveTypeName = CASUAL;
RequestStatus = C;
Shift = "<null>";
ShiftName = "";
SystemLeaveTypeCode = CAS;
TomorrowLeaveCount = 0;

}]

Я хочу сравнить эти объекты, и только 1 объект должен быть добавлен в новый массив. Я не могу использовать "==" для сравнения 2 словарей. Как я могу это сделать? Пожалуйста, помогите мне Спасибо

РЕДАКТИРОВАТЬ

if((obj==previouldObj)==false)
                            {
                                 self.arrayForTable.append(obj)
                            }

Тогда вне класса public func ==(lhs: [AnyHashable: Any], rhs: [AnyHashable: Any] ) -> Bool { return NSDictionary(dictionary: lhs).isEqual(to: rhs) }

0 ответов

Другие вопросы по тегам