I'm trying to create a string with multiple lines but when i keep appending the string with /n, "/n" actually is printed in the string. And I'm trying to create the string from an array so thats the reason for all the for loops.
And what is printed in the output is "first row:element:element1:element2:/nsecond row:element:element1:element2:/n". Any ideas on how to fix this?
Code:
-(void)saveSchedule
{
NSLog(@"saving schedule");
NSError *error;
NSArray *tempArray =_schedule;
NSString *stringFilepath = @"Schedule.txt";
NSMutableString *result = [[NSMutableString alloc] initWithCapacity:1000];
for(NSArray *temp in tempArray)
{
int i = 0;
for (NSObject *obj in temp)
{
if (i==3)
{
for(NSString *number in temp[3])
{
[result appendString:[number description]];
}
[result appendString:@":"];
}else
{
[result appendString:[[NSString alloc] initWithFormat:@"%@%@",[obj description], @":"]];
}
i++;
}
[result appendFormat:@"/n"];
}
NSLog(result);
[result writeToFile:stringFilepath atomically:YES encoding:NSWindowsCP1250StringEncoding error:&error];
}