Reputation: 4925
This question is also asking what type of things I better pass as an argument to a class method vs. having as a property of a class?
For example, if we have a method func
which operates on name
of the class, then I got two options here:
@property (nonatomic) NSString *name;
- (void)func;
OR
- (void)funcWithName:(NSString*)name;
Both look as a valid design by ObjC to me.
However, it's no clear to me how the user of the class is expected to know that he will need to set the name
property before calling func
? and If this is not an appropriate usage of the property, then what use cases it is an appropriate usage for a non-readonly property?
Upvotes: 0
Views: 37
Reputation: 536047
You're comparing apples with oranges. The two architectures you've suggested have nothing to do with each other.
If the class needs a name
property for some reason, it should have a name
property.
If the method needs a new string passed to it, it should have a string parameter.
Upvotes: 1