I have a space-separated string like @"abc xyz http://www.example.com aaa bbb ccc".
How can I extract the substring @"http://www.example.com" from it?
I have a space-separated string like @"abc xyz http://www.example.com aaa bbb ccc".
How can I extract the substring @"http://www.example.com" from it?
Here is my version of the script... Hopefully it's clean and easy to implement. It does a substr of the characters based on limits... Mine is used for a textarea, but can obviously be adapted to textfields :)
-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
int maxLength = 100;
int currentLength = [self.messageField.text length];
if( currentLength > maxLength )
{
NSString *newMessageText = [self.messageField.text substringWithRange:NSMakeRange(0, maxLength)];
[self.messageField setText:newMessageText];
return NO;
}
else
{
return YES;
}
}