Reputation: 993
#import "DatePickerViewController.h"
#import <Parse/Parse.h>
@interface DatePickerViewController ()
@end
@implementation DatePickerViewController
@synthesize dateLabel;
@synthesize pick;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
UIBarButtonItem *saveDate = [[UIBarButtonItem alloc]
initWithTitle:@"Save Date"
style:UIBarButtonItemStyleDone
target:self
action:@selector(saveList:)];
self.navigationItem.rightBarButtonItem = saveDate;
pick = [[UIDatePicker alloc] init];
[pick setFrame:CGRectMake(0,200,320,120)];
[pick addTarget:self action:@selector(updateDateLabel:) forControlEvents:UIControlEventValueChanged];
}
-(void)saveList:(id)sender {
// need to finish
}
-(IBAction)updateDateLabel {
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateStyle:NSDateFormatterLongStyle];
[formatter setTimeStyle:NSDateFormatterMediumStyle];
dateLabel.text = [NSString stringWithFormat:@"%@", [formatter stringFromDate:pick.date]];
}
Upvotes: 0
Views: 394
Reputation: 43330
Your registration for events from the picker is using a selector that expects one argument (@selector(updateDateLabel:)
expects a method of the form -updateDateLabel:(id)arg
), whereas what you have implemented takes no arguments (-updateDateLabel
)
Of course, all of this is moot considering that you've reassigned your picker from the one that was de-archived from the storyboard. Remove the initialization code and hook up the IBAction to the picker in the storyboard.
Upvotes: 1
Reputation: 645
Change -(IBAction)updateDateLabel {
to -(IBAction)updateDateLabel:(id)sender {
Upvotes: 0