I have a text document that I created and added hundreds of words to it, 1 for each line. I creating a little helper app to convert these, then resave to a text file. Then I can copy / paste them into an NSArray for my program since they are already formatted.
My string needs to look like this @"@"Driving","; So I am taking the word Driving and adding @" in front of it and then another quotation mark and coma at the end like this ",
The NSString also has the @""; formatting around that. When I write a new text file to the desktop I can then just copy / paste that information into my NSArray.
I didn't want to have text documents to be imported into my main app so I thought I could write a little helper program to convert these, then just paste the Array entries in with the proper formating.
My code
I thought I could just escape the quote like so \" but when I add it to the array I ended up with this
Is there a way to correctly escape the quotes to do this?
My string needs to look like this @"@"Driving","; So I am taking the word Driving and adding @" in front of it and then another quotation mark and coma at the end like this ",
The NSString also has the @""; formatting around that. When I write a new text file to the desktop I can then just copy / paste that information into my NSArray.
I didn't want to have text documents to be imported into my main app so I thought I could write a little helper program to convert these, then just paste the Array entries in with the proper formating.
My code
Code:
-(void)parseData{
NSArray *lines = [contentsOfFile componentsSeparatedByString:@"\n"];
for (NSString *aKey in lines) {
if (aKey.length != 0) {
NSString *saveString = [NSString stringWithFormat:@"@\"%@\"",aKey];
[fileBreakDown addObject:[saveString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]];
}
NSLog(@"%@", fileBreakDown);
}
}
I thought I could just escape the quote like so \" but when I add it to the array I ended up with this
instead of what I wanted which would be2012-09-08 13:23:21.556 Convert text files[914:403] (
"@\"Administration\",",
"@\"advanced math \",",
"@\"alchemy \",",
@"Administration",
Is there a way to correctly escape the quotes to do this?