I run into a fairly common scenario in Objective-C where I pass in a variable to an init method and then want to assign it to an instance variable of the same name. However
For setters (and by extension initializers), I believe the convention is to prefix the parameter name with new
:
- (void)setCrunk:(Crunk *)newCrunk;
- (id)initWithCrunk:(Crunk *)newCrunk;
In general, I think the most common form I've seen is to call the parameter theCrunk
, but Apple seems to recommend aCrunk
.
And changing the name to "inValue" is not a good idea? What you have here - your 'solution' is complex, especially with the accessors, etc of Obj-C 2. Since self.value and inValue are different things, they need different names.
Note that you can use
-(void)method1:(NSString*)value;
in the header
and
-(void)method1:(NSString*)inValue;
in the .m file.
If you use only 1 the compiler will give you a warning.
You can combine 1 & 2 by using :
@synthesize value = _value;
If you want to hide your variable from the inheritors you can declare a empty named category and declare your property there.
For 3 you can use aValue for your argument.