title: Accessing instance variables of a parent class, from its child
body: <p>I have been learning Objective C for the iPhone for some weeks now, and today got my provisioning profile through, so wanated to put my app on my phone. However when I built it for my iPhone I got a list of errors (almost identical) of the type: </p>
  
  <pre><code>error: 'itemPickerView' undeclared (first use in this function)
  </code></pre>
  
  <p>When I built this for the simulator, this does not happen.</p>
  
  <p>The errors all happen in a single class implementation file (ProjectSettingsController) which extends DetailController.</p>
  
  <p>I have 2 other classes that also extend DetailController, and make use of the same instance variables as ProjectSettingsController does, but they do not cause errors.</p>
  
  <p>ProjectSettingsController is slightly different, as the view it manages is never directly added to the navigation controller, however the compiler wouldnt know this at the time, and it works correctly on the simulator (both running IOS 4.3)</p>
  
  <p>I guess my question is two fold:</p>
  
  <ol>
  <li><p>Why would something give me a compiler error when compiling for a device, and not when compiling for the simulator?</p></li>
  <li><p>Why is it giving me this error at all, only on this one class?</p></li>
  </ol>
  
  <p>Here is the .h for DetailController</p>
  
  <pre><code>@interface DetailController :      UITableViewController&lt;UIPickerViewDelegate,UIPickerViewDataSource&gt;  {
      NSMutableDictionary * data;
      NSMutableArray * dataOrder;
      NSMutableDictionary * objectToData;
      UIDatePicker * pickerView;
      UIPickerView * itemPickerView;
      UIBarButtonItem * doneButton;
      UIBarButtonItem  *  savedRightButton;
      UIBarButtonItem  *  savedLeftButton;
      UIBarButtonItem * insertButton;
      UIView * slidingView;
      UITextView * textView;
      BOOL isEditing;
  }
  </code></pre>
  
  <p>Here is the .h for ProjectSettingsController</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  #import "DetailController.h"
  #import "Project.h"
  #import "Task.h"
  @class ProjectController;
  
  @interface ProjectSettingsController : DetailController{
  }
  @property (nonatomic, retain) ProjectController* parent;
  @property (nonatomic, retain) UINavigationController * navigationController;
  @property (nonatomic, retain) UINavigationItem * navigationItem;
  @property (nonatomic, retain) Project* project;
  </code></pre>
  
  <p>ProjectController is declared as a class, as opposed to included, as it already includes this class. I have tried adding DetailController as @class it did nothing, as I expected it would.</p>
  
  <p>Here is a snippet of an offending piece of code from ProjectSettingsController.m</p>
  
  <pre><code>int hours = [itemPickerView selectedRowInComponent: 0] + 1;
  </code></pre>
  
  <p>Here is the .h for TaskController which works correctly</p>
  
  <pre><code>#import "DetailController.h"
  #import "Task.h"
  #import "Project.h"
  #import "CompletionSlider.h"
  
  @interface TaskController : DetailController{
  
  }
  </code></pre>
  
  <p>And here is a snippet of code from TaskController.m that works.</p>
  
  <pre><code>[itemPickerView selectedRowInComponent:0]+1]
  </code></pre>
  
  <p>I have gone over the ins and outs of the two files for about 2 hours now, and can't find any reason why this would be happening.</p>
  
  <p>Should I change the code to use properties, which would then meen going through my code and putting a super. in front of all of these variables? It seems silly to not be able to access instance variables from within a child class (especially since I seem to be able to access the methods?!)</p>
  
  <p>I look forward to being told what silly thing it is that I have missed</p>