iphone - Create Event with NSDate -
is there way create events nsdate ? here code
nsdate *date = [nsdate date]; nsdateformatter *dateformatter = [[[nsdateformatter alloc] init] autorelease]; [dateformatter setdateformat:@"mmmm d, yyyy"]; nsstring *datestr = [dateformatter stringfromdate:date]; mydate.text = datestr;
for example if date = 12 feb ; mydate .text = @"mother day";
something
sure is. have split date day , month using nsdatecomponents
you write method this:
- (bool)date:(nsdate *)date issameasday:(nsinteger)day andmonth:(nsinteger)month { nsuinteger dateflags = nsdaycalendarunit | nsmonthcalendarunit; nsdatecomponents *components = [[nscalendar currentcalendar] components:dateflags fromdate:date]; if ([components day] == day && [components month] == month) { return yes; } return no; }
and use this
if ([self date:[nsdate date] issameasday:12 andmonth:2]) { mydate.text = @"mother day"; }
Comments
Post a Comment