Reputation: 161
// myClass.h
@interface myClass : NSObject {
int variable1;
}
- (int) addOne: (int)variable1;
//myClass.m
- (int) addOne: (int)variable1{
variable1++;
}
My question is: will [myClass addOne:aNumber]
add 1 to aNumber
or will it add 1 to the value of the ivar variable1
?
Upvotes: 1
Views: 147
Reputation: 39916
It will add one to aNumber in order to add one to ivar you will have to write self.variable1 += 1, I think even ++ may work.
Upvotes: 0
Reputation: 170839
Local variable (or function parameter) hides instance variable declaration (you should get compiler warning about that) - so local copy of aNumber will be incremented.
Upvotes: 3