I'm trying to do a NSCountedSet
but I need to ignore a property, I tried overriding the isEqual
method of my object, and doing a manual compare of all the properties except the one I want to ignore but it doesn't work
Any idea on how to achieve it?
UPDATE
My class
@interface GSOrderMenuMenuContent : GSBaseModel
@property (copy, nonatomic) NSNumber *order_content_id;
@property (copy, nonatomic) NSNumber *item_id;
@property (copy, nonatomic) NSNumber *price;
@property (copy, nonatomic) NSNumber *priceWithModifiers;
@property (copy, nonatomic) NSString *course;
@property (copy, nonatomic) NSString *itemName;
@property (nonatomic) GSMenuItem* item;
@property (nonatomic) NSMutableArray *modifiers;
@property (copy, nonatomic) NSNumber *isAlreadyPrinted;
@property (copy,nonatomic) NSNumber *isDeleted;
-(GSOrderMenuMenuContent*)deepCopy;
-(GSOrderContent*) orderContent;
-(BOOL)isEqual:(GSOrderMenuMenuContent*)object;
@end
Usage:
NSCountedSet* countedSet = [[NSCountedSet alloc] initWithArray:contents];
Where contents is an array of class objects
Adding a breakpoint to the isEqual
gets not called (however it is if doing a [NSarray containsObject:...]
As mentioned in the docs for the
isEqual:
method, you must always implement a correspondinghash
method. Those two methods must always be implemented together.Two objects that compare as equal must also return the same
hash
value.