OK, I need help.
I am trying yo add label values. Ie. buttonpLabel is = 10, rbuttonLabel =2
I was thinking I could somehow find the value for self.buttonfLabel.text and add them to self.rbuttonLabel.text.
I want to present the answer in wLabel
I just can’t figure out the semantics …..
Any ideas?
J
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context {
NSNumber *newValue = [change valueForKey:NSKeyValueChangeNewKey];
NSNumber *supertotals;
// change gives back an NSDictionary of changes
// update the appropriate label
if (keyPath == @"buttonf") {
self.buttonfLabel.text = [newValue stringValue];
}
else if (keyPath == @"rbutton") {
self.rbuttonLabel.text = [newValue stringValue];
}
else if (keyPath == @"pbutton") {
self.pbuttonLabel.text = [newValue stringValue];
}
/////////////below does not work.....
supertotals = [numberWithInt:[bbuttonLabel.text intValue]]+[numberWithInt:[buttonp Label.text intValue]];
self.wLabel.text = [supertotals stringValue];
NSNumber‘s are classes and can not be added together to produce anotherNSNumberwith the new value (You may see this behavior in other languages but that is a result of operator overloading and is not supported in Objective-C). Change the code to something similar to this: