There is a valid file with the name level1.lvl line in it:
10;24;cube1 14;55;cube2 итд...
It is required to read this file and fill in 3 arrays: This is what you must do to contain db1-3 arrays after reading 1 line:
db1 [0] = 10;
db2 [0] = 23;
db3 [0] = cube1;
I am engaged in Objective-C for a couple of days, I can’t catch up on how to implement this.
Supplemented.
Right?
NSString* fileName = @"filename.txt"; NSString *fileString = [NSString stringWithContentsOfFile: fileName]; NSArray *lines = [fileString componentsSeparatedByString:@"\n"]; NSUInteger count = [lines count]; NSUInteger i; for(i = 0; i < count; i++) { NSArray *readed = nil; NSString *element = [lines objectAtIndex:i]; NSArray *readed = [element componentsSeparatedByString: @";"]; [block_x objectAtIndex:i] = [readed objectAtIndex:0]; [block_y objectAtIndex:i] = [readed objectAtIndex:1]; [block_type objectAtIndex:i] = [readed objectAtIndex:2]; }