user2141310
user2141310

Reputation:

NSDatePicker Error

Ever time I try to make a string in xcode it won't work can someone point out what's wrong and help please

        NSString *date = self.DatePicker.date; 

This is the error "Incompatible pointer types initializing 'NSString * strong' with an expression of type 'NSDate *'"

Upvotes: 0

Views: 192

Answers (1)

Anoop Vaidya
Anoop Vaidya

Reputation: 46533

self.DatePicker.date; returns date.

You are storing it in NSString.

Use:

NSDate *date = self.DatePicker.date; 

Then if you want to store it in string then use:

NSString *dateString = [NSDateFormatter localizedStringFromDate:[NSDate date] 
                                                  dateStyle:NSDateFormatterShortStyle 
                                                  timeStyle:NSDateFormatterFullStyle];

Upvotes: 3

Related Questions