Fixed crash when the date for a history item could possibly be formatted as null.

This commit is contained in:
GRMrGecko 2011-02-01 12:06:59 -06:00
parent e44743fbae
commit 9ebac37394

View File

@ -366,7 +366,11 @@ static MGMController *MGMSharedController;
NSMenuItem *item = [[NSMenuItem new] autorelease]; NSMenuItem *item = [[NSMenuItem new] autorelease];
NSDateFormatter *formatter = [[NSDateFormatter new] autorelease]; NSDateFormatter *formatter = [[NSDateFormatter new] autorelease];
[formatter setDateFormat:@"MMMM d, yyyy h:mm:ss a"]; [formatter setDateFormat:@"MMMM d, yyyy h:mm:ss a"];
[item setTitle:[formatter stringFromDate:[historyItem objectForKey:MGMHDate]]]; NSString *date = [formatter stringFromDate:[historyItem objectForKey:MGMHDate]];
if (date!=nil)
[item setTitle:date];
else
[item setTitle:[NSString stringWithFormat:@"%@", [historyItem objectForKey:MGMHDate]]];
[item setRepresentedObject:[historyItem objectForKey:MGMHURL]]; [item setRepresentedObject:[historyItem objectForKey:MGMHURL]];
[item setTarget:self]; [item setTarget:self];
[item setAction:@selector(copyHistoryItem:)]; [item setAction:@selector(copyHistoryItem:)];