1

Possible Duplicate:
Replace tab in NSString with \t

As per the title: is there a way to convert tabs (\t) into white space when loading a text file into an NSString? I am trying to convert a text file and they're giving me trouble.

Community
  • 1
  • 1
Dionysis
  • 804
  • 8
  • 25
  • @H2CO3 hehe fair enough. I was actually looking for a convinience method that would save me from doing it manually. – Dionysis Oct 18 '12 at 22:25
  • 1
    @Dionysis In this case, I revoked my downvote, but next time please be precise and make sure you specify that you've seen the documentation and found something but you're dissatisfied with that. –  Oct 19 '12 at 04:49

1 Answers1

3

This should work:

NSString *test = @"hi\tsecond column\t";
NSString *stringWithWhiteSpace = [test stringByReplacingOccurencesOfString:@"\t" withString: @" ";

test is just a test string that would be the text file you're loading. stringWithWhiteSpace is the string with white space instead of tabs.

pasawaya
  • 11,515
  • 7
  • 53
  • 92