I am still participating in Objective-C, so forgive me if this is a simple amateur error, but I think we all need to learn something.
Basically, I have an application with a simple bit of text in the screen title, which was IBOutletted and called 'headerText'. I want this to read February Summary, replacing February with any month — so the month should appear dynamically.
- (void)setHeaderText {
NSString *headerTextTitle;
NSString *monthString;
NSDate *month;
NSDateFormatter *dateFormat;
month = [[NSDate alloc] init];
[dateFormat setDateFormat:@"MMMM"];
monthString = [dateFormat stringFromDate:month];
headerTextTitle = [[NSString alloc] initWithFormat:@"Summary for (%@)", monthString];
headerText.text = headerTextTitle;
[headerTextTitle release];
[monthString release];
[month release];
[dateFormat release];
}
I obviously can change the text and stuff, but found that the application will work when I call this method in viewDidLoad. Can someone tell me what happened? I THINK these errors on this line:
[dateFormat setDateFormat:@"MMMM"];
Because using breakpoints is a little ridiculous here. What am I doing wrong? I'm pretty confused.
!
EDIT: :
month = [[NSDate alloc] init];
dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"MMMM"];
monthString = [dateFormat stringFromDate:month];
?