0
我有一個NSArray的這種方式IOS:問題同步的NSArray與串
myArray[0] = [string1, string2, string3, string4, mySecondArray, string5]; (at 0 position)
我寫這個陣列的txt文件內以這種方式
NSString *outputString = @"";
for (int i = 0; i< myArray.count; i++){
outputString = [outputString stringByAppendingString:[[[myArray objectAtIndex:i ] componentsJoinedByString:@"#"] stringByAppendingString:@";"]];
}
NSLog(@"string to write = %@", outputString);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"Text.txt"];
NSError *error;
[outputString writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:&error];
然後NSLog的結果爲= (位置myArray的0)(mySecond數組爲空)
one#two#three#four#(
)#five;
我想知道:
- 爲什麼數組包裝?
- 當我去讀這個字符串時,我怎麼知道它是mySecondArray?