Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with NSDate in NSUserDefaults

I'm using NSUserDefaults and I have the code mondayalarm = [prefs stringForKey:@"mondayalarm"]; and mondayalarm (first reference, not the key) is an NSDate. It's giving me the warning:

incompatible Objective-C types assigning 'struct NSString *', expected 'struct NSDate *'

How can i make it accept this without the warning?

like image 550
Andrew Avatar asked Jul 12 '26 22:07

Andrew


1 Answers

To prevent the warning:

mondayalarm = (NSDate*)[prefs stringForKey:@"mondayalarm"];

To fix your problem:

mondayalarm = [prefs objectForKey:@"mondayalarm"];
like image 81
mvds Avatar answered Jul 14 '26 12:07

mvds



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!