StuartM StuartM - 4 months ago 10
iOS Question

Incompatible pointer types initializing 'NSDate

I am setting up some constants, one being an NSDate but receiving this wanring message:

Incompatible pointer types initializing

NSDate *const __strong
with an expression of type

Simple explanation of code (imp file):

NSDate *const kPAPUserBirthdayKey = @"fbBirthday";

Advanced explanation:
I use a constants file as a singleton holding constant variables for the API i write to. For example the above which is a Date field which will hold the facebook users birthday when connecting to Facebook.

This is then later used in the following conversion:

// Convert the DOB string into Date format
NSDateFormatter* df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"MM/dd/yyyy"];
NSDate* userDOB = [df dateFromString:user.birthday];
[[PFUser currentUser] setObject:userDOB forKey:kPAPUserBirthdayKey];

Can someone explain what the warning actually means and what should be changed here? I get the same error on the last line of the above?

NSDate *const kPAPUserBirthdayKey = @"fbBirthday";

You are assigning a string to a NSDate.

Change NSDate to NSString.


NSString const *kPAPUserBirthdayKey = @"fbBirthday";

Also check what you need ?

A constant pointer or pointer to a constant.