Note that there are some explanatory texts on larger screens.

plurals
  1. POReading a .csv into NSObjects and then sorting them by different criterias
    text
    copied!<p>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.</p> <p>I have a huge (!) list of ships in a .csv file, separated by <code>,</code></p> <p>The matrix is organised like this: <img src="https://i.stack.imgur.com/oYtou.png" alt="enter image description here"><br> repeated with different data about 500 times. </p> <p>Now, I want this to be read into objects, which can be used further to populate a <code>UITableView</code> Currently, I hard-code data into the object files, like this </p> <pre><code>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"; </code></pre> <p>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.</p> <p><strong>So, to the question!</strong> How can I read the .csv file that looks like this: <img src="https://i.stack.imgur.com/Q7xTW.png" alt="enter image description here"> add the ships of, say, owner, to a <code>NSMutableArray</code>, in the shape of objects. (So they can be used to feed my <code>UITableView</code> with ships. </p> <p>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. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload