|Jul 17, 2007, 05:01 AM||#1|
Newbie question: keeping track of my objects (Obj-C)
I'm a complete Cocoa newbie and I'm writing a simple program that parses a text file containing multiple DNA sequences. So far, the program parses the file such that the DNA sequences and sequence names are stored in 2 NSMutableArrays (I realise that NSDictionary might be more appropriate with the sequence name as the key, but I haven't got round to that yet).
So far so good. However, I'm now wanting to have an instance of my new Sequence class to encapsulate the sequence and sequence name so that I can easily query the object for, say, various subsections of the sequence or the sequence length. Does this make sense? If the file contains 10 sequences, I'll have 10 sequence objects with methods like - (int)length and - (NSString)reversecomplement (for retrieving the other DNA strand).
So, I've made my file parsing code allocate and initialise a sequence object for each sequence it finds in the file. But my question is this: after the objects are initialised, what is the standard way of keeping track of them? Do I use an NSDictionary, an NSArray or is there a standard way of doing this that I'm missing? Basically if I have a sequence object whose sequenceName is Foo, how do I find it again after it's been created?
I've searched these forums and Google for an answer to this, but with little success... Any help is appreciated!
|Jul 17, 2007, 06:53 AM||#3|
Wow, hang on there! Core Data is a pretty advanced topic.
Richy, first of all, your approach is absolutely right. Encapsulating each sequence in an object is good design.
You do need to keep track of the objects you create. The code that parses the file should store the sequence objects in an NSArray, and return that to another part of your code or store it as necessary.
For example, your app might have a controller object that asks the parser to process a file, and then stores the resulting array of sequence objects in an instance variable. Your user interface and other objects can later query the controller for the array of sequences.
|Jul 17, 2007, 07:47 AM||#4|
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|keeping track of the urrent first responder||Mark FX||Mac Programming||10||Feb 8, 2013 03:36 PM|
|Good app for keeping track of grades? (student)||MasterHowl||Mac Applications and Mac App Store||7||Jan 14, 2013 12:41 PM|
|Keeping track of edited images in iPhoto||ozaz||Mac Applications and Mac App Store||0||Jan 13, 2013 07:47 AM|
|Newbie question - how can I track my new iMac order?||jackofharts||iMac||2||Dec 12, 2012 04:25 AM|
All times are GMT -5. The time now is 11:55 PM.