I have a UILabel for a calculator (this is for the CS193P graphing calculator). I would like to parse the current operand, which would be the rightmost value following an operator. For example, X+3 would need to parse the 3.
What is the easiest way to do this? Also, in trying to assign values back-and-forth between an NSString and this UILabel, I’ve received casting errors. Could someone explain the rationale behind having UILabel and NSString requiring explicit casting? It seems to me they should both be treated as strings.
You need to use .text property of UILabel which is an NSString. Therefore you don’t need casting while using text property.
Also you can use
characterAtIndex:method of NSStrings with the length method of your label’s text.like this
[yourLabel.text characterAtIndex:([yourLabel.text length]-1)];