Note that there are some explanatory texts on larger screens.

plurals
  1. POObjective-C for iPhone - app crashing when using simple date commands
    primarykey
    data
    text
    <p>I'm still learning Objective-C so forgive me if this is a simple amateur mistake, but I guess we all have to learn somehow.</p> <p>Basically I have an app with a simple bit of text, at the header of the screen, which has been IBOutletted and called 'headerText'. I want this to read "Summary for February", replacing February with whatever month it is - so the month must be fetched dynamically.</p> <pre><code> - (void)setHeaderText { NSString *headerTextTitle; NSString *monthString; NSDate *month; NSDateFormatter *dateFormat; month = [[NSDate alloc] init]; // Automatically fills in today's date [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]; } </code></pre> <p>I can obviously modify the text and stuff, but I find the app crashes whenever I call this method on viewDidLoad. Could anyone tell me what's wrong? I THINK it errors in this line here:</p> <pre><code>[dateFormat setDateFormat:@"MMMM"]; </code></pre> <p>Because when using breakpoints stuff goes a bit funny there. What am I doing wrong? I'm rather confused.</p> <p>I appreciate the help!</p> <p>Jack</p> <p>EDIT: I'm now doing this:</p> <pre><code>month = [[NSDate alloc] init]; // Automatically fills in today's date dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat:@"MMMM"]; monthString = [dateFormat stringFromDate:month]; </code></pre> <p>But it's still failing?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload