Storing and retrieving a value and updating it
I am creating an iphone app with objective-c. I have a math problem I need help on. I am new at this so I need to keep it simple. Any sample code would be appreciated.
This is the problem I wa开发者_如何学Gont to display
person A (UItext input ) earns $x a day(UIText input) and keeps a total $y(UILabel).
person b (UItext input ) earns $x a day(UIText input) and keeps a total $y. person c (UItext input ) earns $x a day(UIText input) and keeps a total $y. Grand Total= $z
I can not figure out how I store total , retrieve it, then update the total value.
One approach is to create an array of Person objects that have name, earnings and savings properties. Then use collection operators to calculate the "grand total". Refer to Key Value Coding Programming Guide
NSNumber *grandTotal = [people valueForKeyPath:@"@sum.savings"];
[grandTotalLabel setText:[grandTotal stringValue]];
I know this is not the answer to your question, but you need to watch the free videos from Stanford University on iTunes U. iPhone Application Development (Winter 2010) It will give you a basic understanding of developing for iOS platform.
Then when you are finish watching those, follow this How To Create A Simple iPhone App tutorial step by step. Trust me.
精彩评论