@@ -172,7 +172,7 @@ - (void)linkWithIncluded:(JSONAPI*)jsonAPI {
172
172
173
173
JSONAPIResource *linkedResource = included[linkType][linksToId];
174
174
if (linkedResource != nil ) {
175
- [linkedResources addObject: linkedResources ];
175
+ [linkedResources addObject: linkedResource ];
176
176
}
177
177
}
178
178
}
@@ -226,6 +226,15 @@ - (id)copyWithZone:(NSZone *)zone {
226
226
227
227
}
228
228
229
+ BOOL isEmptyDictionary = !self.__dictionary || self.__dictionary .count == 0 ;
230
+
231
+ if (isEmptyDictionary) {
232
+ for (NSString *key in self.propertyKeys ) {
233
+ id selfValue = [self valueForKey: key];
234
+ [copy setValue: selfValue forKey: key];
235
+ }
236
+ }
237
+
229
238
return copy;
230
239
}
231
240
@@ -302,4 +311,32 @@ - (void)encodeWithCoder:(NSCoder *)aCoder
302
311
}
303
312
}
304
313
314
+ #pragma mark - NSObject -
315
+
316
+ - (BOOL )isEqual : (id )object
317
+ {
318
+ if (self == object) return YES ;
319
+ if (![object isMemberOfClass: [self class ]]) return NO ;
320
+
321
+ for (NSString *key in self.propertyKeys ) {
322
+ id selfValue = [self valueForKey: key];
323
+ id objectValue = [object valueForKey: key];
324
+
325
+ BOOL valuesEqual = ((selfValue == nil && objectValue == nil ) || [selfValue isEqual: objectValue]);
326
+ if (!valuesEqual) return NO ;
327
+ }
328
+
329
+ return YES ;
330
+ }
331
+
332
+ - (NSUInteger )hash {
333
+ NSUInteger value = 0 ;
334
+
335
+ for (NSString *key in self.propertyKeys ) {
336
+ value ^= [[self valueForKey: key] hash ];
337
+ }
338
+
339
+ return value;
340
+ }
341
+
305
342
@end
0 commit comments