daihovey
daihovey

Reputation: 3575

can i get data from the object from observeValueForKeyPath iphone

I want to get a number of variables from the target of the function

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context

but XCode wont compile if I say object.somevalue - I am using [change objectForKey:@"new"] to get the changed value, but I want to get more values and I dont want to break the MVC I've got setup.

Upvotes: 0

Views: 245

Answers (1)

coneybeare
coneybeare

Reputation: 33101

The compiler does not know what Class object is, it only know where to find it (through the id pointer). It won't let you compile code that accesses somevalue because it doesn't know where to go looking for it. Thus, you either have to cast the object to what you know it is, or send it a message using the bracket notation: [object somevalue] and live with the warning it gives.

Upvotes: 1

Related Questions