Questions about [self]


#1

Hi,

I was wondering in the Solution to the ToDo List, I see that you use [[self objectvariable-etc] count] (so some other function), instead of simply [objectvariable-etc count]

I had coded my class originally using just the [objectvariable-etc] as the receiver not [self object variable-etc], though it still worked. Was there any reason why it should be done one with the [self objectvariable-etc] as the receiver?

thanks
James


#2

I’m not sure, since I’m currently trying to learn Objective-C myself, but it has to do with proper memory management. By calling the self, you use the proper setter and release the old value before assigning the new.