Properties / instance variables are not magically initialized for you. When you say:
@property (strong, nonatomic) TracksMotion *motionTracker;
... you are just reserving memory space for an instance variable (and generating a getter and a setter method through @synthesize
or autosynthesis). There is no actual TracksMotion object there until you put one there. You must write code to do that. You must create or obtain a TracksMotion instance and assign it to self.motionTracker
at some point, presumably early in the life of self
(in this case, that's a ViewController instance). Until you run code that does that, self.motionTracker
is nil.
(It is possible that you are being confused because it looks like outlets are automatically initialized. For example, you've got @property (weak, nonatomic) IBOutlet UIButton *startRecording;
And sure enough, self.startRecording
is a button. But that's because the nib-loading process does for you the very thing I'm saying you must do: it makes a button from the storyboard or .xib file, and assigns it to this instance variable.)