This is more a open question than an error-related question, so if you don't like to answer these kinds of questions, please don't flame.
I have a huge (!) list of ships in a .csv file, separated by ,
The matrix is organised like this:
repeated with different data about 500 times.
Now, I want this to be read into objects, which can be used further to populate a UITableView
Currently, I hard-code data into the object files, like this
arrayWithObjectsForTableView = [[NSMutableArray alloc] init];
if ([boatsFromOwner isEqualToString:@"Owner1"]) {
cargoShips* ship = [[cargoShips alloc]init];
ship.name = @"name1";
ship.size = 1000;
ship.owner = @"Owner1";
[self.boatsForOwner addObject:ship];
ship = [[cargoShips alloc]init];
ship.name = @"Name 2";
ship.size = 2000;
ship.owner = @"Owner2";
And so on and on with if-else's. This is a bad method, as 1) Its boring and takes a long time 2) It takes even more time if I want to update the information. So, I figured it would be smarter to read programmatically from the matrix instead of doing it myself. Yeah, captain obvious came for a visit to my brain.
So, to the question!
How can I read the .csv file that looks like this:
add the ships of, say, owner, to a
NSMutableArray
, in the shape of objects. (So they can be used to feed my UITableView
with ships.
I would also like to have the option to sort by different stuff, like Country of build, Operator etc. How can I make code that feeds relevant ships read from the .csv into objects? I don't know much programming, so in-depth answers would be very appreciated.