Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jul 17, 2007, 05:01 AM   #1
richyfp
macrumors member
 
Join Date: Apr 2004
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!
__________________
Bit Wrangling Blog | richpollock.com
richyfp is offline   0 Reply With Quote
Old Jul 17, 2007, 06:23 AM   #2
Eraserhead
macrumors G4
 
Eraserhead's Avatar
 
Join Date: Nov 2005
Location: UK
Core Data could work well...
Eraserhead is online now   0 Reply With Quote
Old Jul 17, 2007, 06:53 AM   #3
Nutter
macrumors 6502
 
Join Date: Mar 2005
Location: London, England
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.
Nutter is offline   0 Reply With Quote
Old Jul 17, 2007, 07:47 AM   #4
richyfp
Thread Starter
macrumors member
 
Join Date: Apr 2004
Quote:
Originally Posted by Nutter View Post
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.
Thank you very much! I think the fact that the question is a little more abstract than e.g. "what method do I use for this?" is probably why Googling didn't throw much up...
__________________
Bit Wrangling Blog | richpollock.com
richyfp is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
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

Forum Jump

All times are GMT -5. The time now is 11:43 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC