If you define a property for a mutable array…
@property (nonatomic, strong) NSMutableArray *objects;
Then you start to write the function… - (void)addObje... then auto complete will finish then name and give you…
- (void)addObjectsObject:(<#object-type#> *)object
{
}
My question is, how should I be using this function?
Do I have to call
[self addObjectsObject:someObject];
or can I just do
[self.objects addObject:someObject];
i.e. will the NSMutableArray property know that I’ve overridden the add object function and use my defined function to add it?
You need to use
[self addObjectsObject:someObject];.[self.objects addObject:someObject];will invoke the NSMutableArray’s method directly on the property.EDIT:
Some more information:
If you want to override your method, you need to sub-class or you can make a category, but do not use same method name to override an existing category.