Disclaimer:
I’ve been learning Objective C/Cocoa for 2 months or so, and I promised myself that I would always try and find the answer myself rather than clogging the internet with dumb noob questions. At this point I’m just confused all over and I think I would benefit at this point from asking questions. I apologize in advance.
Problem:
I’m trying to write a master-detail style app (this is just for practice) called “My Dream Garage”. Basically I want to store car objects and their properties. I have a “Car” class that looks like this:
#import <Foundation/Foundation.h>
@interface Car : NSObject
@property (nonatomic, strong) NSString *brand, *model, *trimLevel;
@property (nonatomic, strong) NSNumber *modelYear, *engineSizeinL, *weight;
@property (nonatomic, strong) id image;
@end
In my main .XIB file I have an NSTableView and a bunch of text labels that will display each property (and an imagewell for the image).
My question is how do I store this data? I understand what NSArray, NSDictionary, ArrayController and DictionaryController are individually. I’m just a little confused on how to make them work together. When I add a new “car”, am I supposed to instantiate a new “Car” object with it’s properties? At that point do I add the new object to an array and then release the created “Car” object? Do I link the tableview and text-labels to an NSDictionary Controller? I’m not even sure what I should be asking at this point.
Perhaps I’m in a bit over my head. What other than Apple’s documentation (which is very good but too verbose for an amateur) would be recommended to learn how to create apps similar to this?
Any help is greatly appreciated. Thank you.
Lots of questions here:
Are you wanting to store them somewhat permanently? If so, you need to start learning Core Data.
What does the implementation file look like for the Car class? How are you (or are you) instantiating and initializing a new object?
My class objects usually look something like this:
Interface:
Implementation:
And I will create a new one with code like this: