I have a feeling this will be too wordy, but I'll do my best. My app has quotes built-in that change each day. Some of them are over 140 characters, but I would like to be able to share via Twitter, so I need a way to get the count, and if over 140, edit it. What I have so far is:
int maxChars = 140;
int charsLeft = maxChars - [label1.text length];
NSString *removed = [label1.text substringToIndex:[label1.text length] - charsLeft];
TWTweetComposeViewController* twc = [[TWTweetComposeViewController alloc] init];
[twc setInitialText:removed];
[self presentModalViewController:twc animated:YES];
Where label1 is the UILabel that shows the quote. This is throwing an error on quotes over 140 characters
[__NSCFString substringToIndex:]: Range or index out of bounds'
Any thoughts? One other thing I was thinking. Each quote ends with
" - Person who said it
I was thinking I could get the character count, remove the excess characters + 3 and insert an ... before the -. How could I go about doing this, or at least fix my existing code?