Skip to content

Instantly share code, notes, and snippets.

@lxcid
Last active December 15, 2015 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lxcid/5289553 to your computer and use it in GitHub Desktop.
Save lxcid/5289553 to your computer and use it in GitHub Desktop.
- (void)modifySelectedString: (NSDictionary *)theAttribute {
NSString *mainString = [self.mainStringLabel.attributedText string];
NSString *queryString = [self selectStringFromMainStringLabelViaStepper];
NSRange selectedStringRange = NSMakeRange(0, mainString.length);
while (selectedStringRange.location != NSNotFound) {
NSRange selectedStringRange = [mainString rangeOfString:queryString options:0 range:selectedStringRange];
if (selectedStringRange.location != NSNotFound) {
[self addAttributeWithRangeToSelectedString:theAttribute range:selectedStringRange];
NSInteger nextIndex = selectedStringRange.location + selectedStringRange.length + 1;
selectedStringRange = NSMakeRange(nextIndex, mainString.length - nextIndex);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment