I use buttons to display letters in a bar now this is the code I use
-(IBAction) clicked: (id)sender{
NSString *titleOfButton = [sender titleForState:UIControlStateNormal];
NSString *newLabelText = titleOfButton;
labelsText.text = [NSString stringWithFormat:@"%@%@", labelsText.text, newLabelText];
//if ([newLabelText length] >= 5) newLabelText = [newLabelText substringToIndex:5];
}
The problem I got is that I want it to be able to put in 5 letters max Is there anyone who can tell me how to do this?
thanks
Add this line –
…or apply the same to whatever string you want to truncate.
Check out the Apple Docs for some really useful NSString stuff