I was wondering something. I tried to get the NSNumber from voltage after i used key-value-coding to set it. Now, this returns an NSNumber object, so i wanted to use the description method to see the value:
And it works great, it prints out 240.
Now, which description method is used here? Coz we overwrote the description method in appliance.m. But the valueForKey is calling the description method from it’s own class, right? It is declared in NSKeyValueCoding.h, so if i wanted to overwrite the description method i would have to access that file and change the description method there, or?
Coz i though the message call went like this: we send the message valueForKey: to the instance that a points to. This method goes up the hierarchy till it finds the valueForKey method in the NSKeyValueCoding class. Then it returns an NSNumber object by getting the value from a’s instance variable voltage, and then returns a pointer to that NSNumber. When we then use the description method, i thought it said the description method on a was being used, thus “self” being appliance. But this isn’t the case i see.
Anyone care to enlighten me? i probably just got something backwards, and i’m sorry if this seems confusing, but hey, try being my mind for a day :=)
Thanks on advance!