I am new to objective-c and object-oriented programming in general and have a theoretical, stylistic type of question. I want to load a class table with entries from a comma-delimited file. The data in the file consists of many records consisting of a short key, followed by several string values, all limited to commas.
There are a million ways to do this, but I ask what would be better than it would be from a theoretical point of view. I would like to stay away from any kind of XML coding for now, but I will probably end up moving to this format as soon as I get the writer together.
I could use the function to get the “next record” and pass the structure to and from the function, create a new instance of the class, load it from the structure and then add it to the array. I would use the stringWithContentsOfFile method to first load the file into a string, then use string functions and some pointers to go through the file to return the elements of the structure that I would then load into the class.
Does this seem like a reasonable way to do this in objective-c, or is there a better method that may sound more theoretical that will work, at least as well?
source
share