Objective-C member variable assignment?
- by Alex
I have an objective-c class with member variables. I am creating getters and setters for each one. Mostly for learning purposes. My setter looks like the following:
- (void) setSomething:(NSString *)input {
something = input;
}
However, in C++ and other languages I have worked with in the past, you can reference the member variable by using the this pointer like this->something = input. In objective-c this is known as self. So I was wondering if something like that is possible in objective-c? Something like this:
- (void) setSomething:(NSString *)input {
[self something] = input;
}
But that would call the getter for something. So I'm not sure. So my question is:
Is there a way I can do assignment utilizing the self pointer?
If so, how?
Is this good practice or is it evil?
Thanks!