help on building a data model
I'm new to Xcode and objective C programming and I'm having some troubles building a data model for my application. Here is how it should look like (pseudo code):
array of persons(Level1Objects)
persons (Level1Object) with ID, name, array of subjects (Level2Objects that contains array of marks for each subject and ID)
subjects (Level2Object) with ID of subject and array of marks
And this is how far I came:
//view controller header
@interface projectOneViewController : UIViewController {
NSMutableArray *persons;
}
@property (nonatomic, copy) NSMutableArray *persons;
->New File... Objective-C Class
//objective-C class header
@interface personData : NSObject
{
NSMutableArray *subjects;
NSString *ID;
NSString *name;
}
@property (nonatomic, copy) NSMutableArray *subjects;
@property (nonatomic, copy) NSString *ID;
@property (nonatomic, copy) NSString *name;
Now in the implement开发者_如何学Pythonation I create class personData and use addObject function to add it to persons and its working fine, but I don't know how to add another level (level2Object) to this data model. Do I have to create another objective-C class? Also if you have any suggestions to improve current model, let me know, I'm pretty new to this.
Thanks in advance!
create another data modal named subject
@interface subject : NSObject
{
NSMutableArray *marks;
NSString *ID;
NSString *name;
}
@property (nonatomic, copy) NSMutableArray *marks;
@property (nonatomic, copy) NSString *ID;
@property (nonatomic, copy) NSString *name;
then allocate subject data modal assign values to it and add to subject array in the first data modal.
精彩评论