Guest User

Untitled

a guest
Jun 20th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. - (NSString *) convertToHtml1:(NSString *)bruteText
  2. {
  3.  
  4.  
  5. //////////////////////// REPLACING @ with <b> </b> //////////////////////////
  6.  
  7. NSString *rezultat = [NSString stringWithString:@""];
  8. NSArray *splits = [bruteText componentsSeparatedByCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"@"]];
  9. NSMutableArray *modifiedArray = [[NSMutableArray alloc] initWithCapacity:[splits count]] ;
  10.  
  11. int i;
  12. for (i=0;i< [splits count];i++ )
  13. {
  14. if (i%2==0)
  15. {
  16. [modifiedArray addObject: [splits objectAtIndex:i]];
  17. }
  18. if (i%2!=0)
  19. {
  20. NSString *alteredText=[[NSString alloc] init];
  21. if (i==1)
  22. {
  23. alteredText = [NSString stringWithFormat:@"%s %@ %s", "<span style=\"font-size:22px; color:blue; font-weight:bold; text-transform:lowercase \" >", [splits objectAtIndex:i], "</span>" ];
  24. }
  25. if (i>=3)
  26. {
  27. alteredText = [NSString stringWithFormat:@"%s %@ %s", "<b>", [splits objectAtIndex:i], "</b>"];
  28. }
  29. [modifiedArray addObject:alteredText];
  30. [alteredText release];
  31. }
  32.  
  33. }
  34. for (i=0;i< [modifiedArray count];i++)
  35. {
  36. rezultat = [rezultat stringByAppendingString:[NSString stringWithFormat:@"%@", [modifiedArray objectAtIndex:i]]];
  37. }
  38. return rezultat;
  39. }
Add Comment
Please, Sign In to add comment