i have string @"greetings capt. ashim mittra, vice president – flight operations"
want extract “capt. ashim mittra”. i.e. want start word “from” , read “,” (comma)
you can like,
nsstring *str = @"greetings capt. ashim mittra, vice president – flight operations"; nsrange range1 = [str rangeofstring:@"from"]; nsrange range2 = [str rangeofstring:@","]; nsrange rangetosubstring = nsmakerange(range1.location + range1.length, range2.location - range1.location - range1.length); nsstring *resultstr = [str substringwithrange:rangetosubstring]; nslog(@"path1 : %@",resultstr);
you can set attributed text label or else when want show text bold portion like,
uifont *font = [uifont boldsystemfontofsize:17.0]; // whatever size, can use diiferent font different method nsdictionary *dict = [nsdictionary dictionarywithobjectsandkeys:font,nsfontattributename, nil]; nsmutableattributedstring *resultstrwithbold = [[nsmutableattributedstring alloc]initwithstring:str]; [resultstrwithbold setattributes:dict range:rangetosubstring]; yourlabel.attributedtext = resultstrwithbold;
Comments
Post a Comment