Properties


#1

Hi to all on the journey learning Objective-C.

I am steady working my way through the book and am getting on quite well. It is great having the forum to see how everyone else is finding it. The thing that is really good, is that the chapters are small, and so I can get through a chapter and the challenge each evening and feel a sense of achievement.

One sticking point I had with the challenge in this chapter was with Properties. Although I understood how how to use them, I had not realised the syntax.

I had declared my instance variables so:

float purchaseSharePrice; float currentSharePrice; int numberOfShares;

but when I came to use the setters, I got the capitalisation wrong:

[apple setpurchaseSharePrice:45.10]; [apple setcurrentSharePrice:49.51]; [apple setnumberOfShares:210];

Once I had corrected it to the following, all was hunky dory:

[apple setPurchaseSharePrice:45.10]; [apple setCurrentSharePrice:49.51]; [apple setNumberOfShares:210];

I hope that this helps anyone else that did not spot it straight away.


#2

Capitalization conventions, I suppose.

What I find strange is when I have some variable name which represents something real - for example “metres” [using the international spelling] - which has the format according to the SI of starting with a lower case “m”. But with these sorts of coding conventions, you end up with things like

   heightInMetres

which just breaks all that SI standardization.

But yes, I agree with the OP here that checking one’s capitalizations is important in this Objective-C animal.