0

Possible Duplicate:
finding location of specific characters in UILabel on iPhone

How can i get the position of a specific string/substring in UILabel ? The UILabel is a multiline label and also has /n characters. Ultimately I should be able to draw another view in place of the position retrieved.

If not UILabel, could a UITextView be used to achieve results as expected above?

Thanks in advance.

Community
  • 1
  • 1
karamojong
  • 41
  • 6
  • Check this http://stackoverflow.com/questions/3191049/finding-location-of-specific-characters-in-uilabel-on-iphone – riti Oct 16 '12 at 09:15

1 Answers1

-1

This code may help you in building logic for the same..

@interface NSString ( containsCategory )
- (BOOL) containsString: (NSString*) substring;
@end

// - - - - 

@implementation NSString ( containsCategory )

- (BOOL) containsString: (NSString*) substring
{    
    NSRange range = [self rangeOfString : substring];
    BOOL found = ( range.location != NSNotFound );
    return found;
}

@end
iCreative
  • 1,499
  • 1
  • 9
  • 22