Object vs. non-object instance variables


#1

I get using object instance variables for to-one and to-many objects but I’m trying to understand the benefit of using object instance variables for simple variables. For example, what’s the benefit of using pointers to a simple variable like “lastName” vs. just storing that variable in the Employee/Person object directly? Any why would you use it for the lastName variable but not employeeID?


#2

How do you propose to do that? By allocating a character array to store the characters in? You could certainly do that but then you would lose the benefits provided by the NSString class. To compensate for that loss, you would have to write more code.

As for the employeeID, it has a numeric value which fits nicely into the scalar types provided by the language; therefore it does not make sense to use a pointer variable for the employeeID. Again, you could do that but then you would have do write more code to handle it.


#3

Thanks, not sure why, but I had a total mental block about that. But after reading your response the clouds parted, sun beams shone down on me and angels started singing. Then one of the angels slapped me upside the head and said “duh!” I guess it didn’t click until just now that C doesn’t have a string type like other languages.