datepicker objects

Hi, I've just finishing copying a datePicker example from a book ( iOS 6 development in 24 hours) , and I've noticed that no instance of the picker object is used, but just a "dragged in"picker from the library on to a view?. i thought i had to create an instance of a picker and declare it in the header file of a view?. Any way , the value of picker is accessed by the method

-(IBaction) setDateTime:(id) sender {

[( viewController *) self.delegate calculateDateDifference:( (UIDatePicker *) sender).date];

}

I guess this code won't make much sense unless you've seen the rest of the exercise, but my point is… is Xcode able to select the only picker object in this way in a view without being more specific ?

apologies if this a ridiculous question, its all a bit new to me still.



p.s the book is great (although 1 hour per chapter is a bit of a stretch!!) ,and have a million questions about other stuff in the book, but i dont know of any forums dedicated to the book. unless anybody else does?

Posted on May 17, 2013 3:57 PM

Reply
1 reply

May 17, 2013 8:03 PM in response to Mike200

When a nib file is loaded, the objects it contains are instantiated. An IBOutlet is needed if you want to associate properties in your application with items in the Interface Editor, but the objects will exist regardless.


The IBaction method is sent the particular object that called it (sender), so depending on what you are doing with the object there doesn't necessarily need to be a separate outlet for it.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

datepicker objects

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.