Andrew
Andrew

Reputation: 16051

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?

Upvotes: 3

Views: 1252

Answers (1)

mvds
mvds

Reputation: 47034

To prevent the warning:

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

To fix your problem:

mondayalarm = [prefs objectForKey:@"mondayalarm"];

Upvotes: 7

Related Questions