Probably a really dumb question but I'm having some trouble. Essentially I'm trying to take a first name and last name from text fields in the storyboard and store both values into one index of an array to call back at another time. Here's what I have:
//File.h
@property NSString *firstName;
@property NSString *lastName;
- initWithFirstName: (NSString *) firstName lastName: (NSString *) lastName;
//File.m
-(id) initWithFirstName: (NSString *) firstName lastName: (NSString *) lastName{
self.firstName = firstName;
self.lastName = lastName;
return self;
}
//ViewController.h
@property File *name;
@property NSMutableArray *array;
//ViewController.m
[super viewDidLoad]
self.array = [[NSMutableArray alloc]init];
self.name = [[File alloc] initWithFirstName: self.firstNameText.text lastName: self.lastNameText.text];
//under the save button
[self.array addObject:self.name];
//under the restore button
self.firstNameText.text = self.array[..?
That part (..?) is where I screw up. I can't go self.array[0].firstName because it doesn't exist. If I put array without an index the same thing happens. I know I must be messing up somewhere, maybe the firstName and lastName aren't even getting stored into the array at all.
Any help is greatly appreciated :)