Reputation: 2836
I have a texfile as follows:
line1
line2
line3
line4
line5
....
I want to read from file into two arrays of string so that line1, line3, line 5,...
go into array1
and line 2, line 4, line 6,...
go into array2
.
Each element of arrays stores one line.
Upvotes: 3
Views: 9110
Reputation: 33421
Step 1) Read file ([NSString stringWithContentsOfFile:encoding:error:]
)
Step 2) Split string ([NSString componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]]
)
Step 3) Iterate over array and insert into your 2 arrays
Upvotes: 5