您好我从我的服务中获得了重复的词典。
[{
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;
}]
我想比较这些对象,并且只应将一个对象添加到新数组中。我不能用“==”来比较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)
}