0

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 *'"

Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
  • "can someone point out what's wrong" - two things are terribly wrong: 1. this is **unrelated to Xcode,** 2. you haven't bothered **reading the documentation nor trying to understand the error message**. –  Mar 09 '13 at 18:09
  • 1. It is related to xcode because the error was in xcode 2. I did google it and looked at about 5 pages and nothing was there –  Mar 09 '13 at 18:14
  • 1
    @Programer1038: xcode is an ide, not a compiler!!! – Anoop Vaidya Mar 09 '13 at 18:14
  • @Programer1038 1. Nor a programming language, nor an API. You can develop iOS apps while completely avoiding Xcode (I do that, for the record). 2. If you read the official documentation of `NSDatePicker`, you would have found out that its `date` property contains an `NSDate`, and not an `NSString`. –  Mar 09 '13 at 18:15
  • What are you talking about. Not everybody is a IOS genius, some just started –  Mar 09 '13 at 18:19
  • I did not even say compiler –  Mar 09 '13 at 18:24

1 Answers1

3

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];
Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140