title: How to Archive/Unarchive data in a TableView w/ delegation?
body: <p>I have 2 Controllers, a AssignmentViewController and a UITableViewController.  Whenever an assignment is created and the saved button is clicked, I need to send that Assignment object to my UITableViewController (Using delegation).  The TableView then needs to archive it in a file in a NSMutableArray (TableView must do the archiving/unarchiving for this app).  </p>
  
  <p>And whenever the TableView is loaded, it needs to unarchive the array and have the Homework Objects displayed in the table cells.</p>
  
  <p>I have the code started, but I don't really know what Im doing correctly and incorrectly.</p>
  
  <p>The app is supposed to work in this order.  Enter assignment info and press save -> send new assignment object to TableViewController using delegation -> Archive object in NSMutableArray to a file ->Whenever Table view is on the screen, unarchive array and display assignment objects in cells.</p>
  
  <p>Here is what I have:</p>
  
  <p>AssignmentViewController.h</p>
  
  <pre><code>@interface Assignment : UIViewController
  
  &lt;
  UITextViewDelegate,
  AssignmentTableControllerDelegate 
  //Error:Cannot find protocol declaration "AssignmentTableControllerDelegate"
  
  &gt;
  @property(nonatomic) IBOutlet UITextField *ClassNameField;
  @property(nonatomic) IBOutlet UILabel *ClassNameLabel;
  @property(nonatomic) IBOutlet UITextField *AssignmentTitleField;
  @property(nonatomic) IBOutlet UILabel *AssignmentTitleLabel;
  
  @property (nonatomic, strong) Homework *homeworkAssignment;
  
  
  - (IBAction)Save:(UIButton *)sender;
  @end
  </code></pre>
  
  <p>AssignmentViewController.m</p>
  
  <pre><code>- (IBAction)Save:(UIButton *)sender {
  
  
  self.homeworkAssignment = [[Homework alloc] init];   
  self.homeworkAssignment.className = self.ClassNameField.text;
  self.homeworkAssignment.assignmentTitle = self.AssignmentTitleField.text;
  
  //Sending info over to TableController
  
  self.assignmentTableController.delegate= self;
  self.assignmentTableController.homeworkInTable.className= self.ClassNameField.text;
   self.assignmentTableController.homeworkInTable.assignmentTitle=self.AssignmentTitleField.text;
  </code></pre>
  
  <p>AssignmentTABLEController.h</p>
  
  <pre><code>#import "Assignment.h"
  
  @protocol AssignmentTableControllerDelegate;
  
  
  @interface AssignmentTableController : UITableViewController
  
  @property (nonatomic, strong) Homework *homeworkInTable;
  @property (nonatomic, assign)  id &lt;AssignmentTableControllerDelegate&gt; delegate;
  @property (nonatomic,strong) NSMutableArray *MyHomeworkArray;
  
  -(IBAction)ArchiveData:(id)sender;
  
  @end
  
  @protocol AssignmentTableControllerDelegate &lt;NSObject&gt;
  
  -(NSMutableArray *)UnarchiveData;
  @end
  </code></pre>
  
  <p>AssignmentTABLECONTROLLER.M (All I did was add these 2 methods)</p>
  
  <pre><code>-(void)ArchiveData:(id)sender
  {
  [self.MyHomeworkArray addObject:self.homeworkInTable];
  
  
  NSString *filePath = [self dataFilePath];//file created
  //Archive my object
  [NSKeyedArchiver archiveRootObject:self.MyHomeworkArray toFile:filePath];
  }
  
  
  -(NSMutableArray *)UnarchiveData
  {
  Homework *archivedHomework = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
                                  //Error:use of undeclared identifier:filePath^^
  
  }
  </code></pre>
  
  <p>I am new to this so I know theres a lot wrong.  I "think" I am passing the info over correctly from AssignmentViewController with delegation.  But I am pretty sure I am not archiving/unarchiving correctly at all. I am not sure how to separate the archiving/unarchiving code and then display in the table.</p>