I have a method signature here:
.h
-(void)addToArray
And I want to use it here:
.m
-(void)viewDidLoad{
NSMutableArray *array = [[NSMutableArray alloc]init];
[array addToArray];
}
-(void)addToArray{
//some code here…
}
The problem is that when I do [array addToArray]; it returns to me a message that says “Instance method ‘-addToArray’ not found (return type defaults to ‘id’)”
How can I solve it?
when you do
[array somemethod]..it will look for the method in that array data type class( that is inNSMutableArrayclass.when you have a method in your own class.and it is not a category…then you must call
this way it will look in the class that is in which you are calling the method.