Reputation: 6451
I have an NSMutableArray
of NSStrings
, which I want to write to a text file, so that each string has its own line.
Any suggestions?
Upvotes: 3
Views: 2029
Reputation: 14662
You can create a full string of your NSMutableArray
with
- (NSString *)componentsJoinedByString:(NSString *)separator
Something like
NSString* fullString = [yourArray componentsJoinedByString:@"\n"];
You can then use
- (BOOL)writeToFile:(NSString *)path atomically:(BOOL)useAuxiliaryFile encoding:(NSStringEncoding)enc error:(NSError **)error
on the fullString
to write it on disk.
Upvotes: 9