File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -219,6 +219,15 @@ - (id)copyWithZone:(NSZone *)zone {
219
219
220
220
}
221
221
222
+ BOOL isEmptyDictionary = !self.__dictionary || self.__dictionary .count == 0 ;
223
+
224
+ if (isEmptyDictionary) {
225
+ for (NSString *key in self.propertyKeys ) {
226
+ id selfValue = [self valueForKey: key];
227
+ [copy setValue: selfValue forKey: key];
228
+ }
229
+ }
230
+
222
231
return copy;
223
232
}
224
233
@@ -295,4 +304,32 @@ - (void)encodeWithCoder:(NSCoder *)aCoder
295
304
}
296
305
}
297
306
307
+ #pragma mark - NSObject -
308
+
309
+ - (BOOL )isEqual : (id )object
310
+ {
311
+ if (self == object) return YES ;
312
+ if (![object isMemberOfClass: [self class ]]) return NO ;
313
+
314
+ for (NSString *key in self.propertyKeys ) {
315
+ id selfValue = [self valueForKey: key];
316
+ id objectValue = [object valueForKey: key];
317
+
318
+ BOOL valuesEqual = ((selfValue == nil && objectValue == nil ) || [selfValue isEqual: objectValue]);
319
+ if (!valuesEqual) return NO ;
320
+ }
321
+
322
+ return YES ;
323
+ }
324
+
325
+ - (NSUInteger )hash {
326
+ NSUInteger value = 0 ;
327
+
328
+ for (NSString *key in self.propertyKeys ) {
329
+ value ^= [[self valueForKey: key] hash ];
330
+ }
331
+
332
+ return value;
333
+ }
334
+
298
335
@end
You can’t perform that action at this time.
0 commit comments