Note that there are some explanatory texts on larger screens.

plurals
  1. POPossible Memory leak with NSDate in Struct
    primarykey
    data
    text
    <pre><code>//h file struct runSTRUCT{ NSDate *RunDateTime; } ; //m file struct runSTRUCT run; - (void)viewDidLoad { [super viewDidLoad]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; dateFormatter.timeStyle = NSDateFormatterNoStyle; [dateFormatter setDateFormat:@"MM/dd/yyyy HH:mm"]; run.RunDateTime = [dateFormatter dateFromString:@"12/02/2012 12:22"]; NSString *dateTimeStr = [dateFormatter stringFromDate:run.RunDateTime]; [dateFormatter release]; } </code></pre> <p>This all works fine. Then when I click a button and make a string from the date, it gives me EXC_BAD_ACCESS.</p> <pre><code>-(IBAction)respondButtonPressed:(id)sender{ NSDateFormatter *dateFormatter2 = [[NSDateFormatter alloc] init]; dateFormatter2.timeStyle = NSDateFormatterNoStyle; [dateFormatter2 setDateFormat:@"MM/dd/yyyy HH:mm"]; NSString *dateTimeStr = [dateFormatter2 stringFromDate:run.RunDateTime]; [dateFormatter2 release]; } </code></pre> <p>When I look in the console and print description, it generally shows 1 of two things:</p> <ol> <li><p>The program being debugged was signaled while in a function called from GDB. GDB has restored the context to what it was before the call. To change this behavior use "set unwindonsignal off" Evaluation of the expression containing the function (CFShow) will be abandoned. The program being debugged was signaled while in a function called from GDB. GDB has restored the context to what it was before the call. To change this behavior use "set unwindonsignal off" Evaluation of the expression containing the function (CFShow) will be abandoned.</p></li> <li><p>Or "run.runDateTime" is some random variable</p></li> </ol> <p>EDIT: I'm not sure if I put these in the right place because it still doesn't work(I probably didn't).</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; dateFormatter.timeStyle = NSDateFormatterNoStyle; [dateFormatter setDateFormat:@"MM/dd/yyyy HH:mm"]; run.RunDateTime = [dateFormatter dateFromString:@"12/02/2012 12:22"]; NSString *dateTimeStr = [dateFormatter stringFromDate:run.RunDateTime]; [run.RunDateTime retain]; [dateFormatter release]; } -(IBAction)respondButtonPressed:(id)sender{ NSDateFormatter *dateFormatter2 = [[NSDateFormatter alloc] init]; dateFormatter2.timeStyle = NSDateFormatterNoStyle; [dateFormatter2 setDateFormat:@"MM/dd/yyyy HH:mm"]; NSString *dateTimeStr = [dateFormatter2 stringFromDate:run.RunDateTime]; [dateFormatter2 release]; } </code></pre> <p>I also have a couple of NSStrings in the struct and they work fine.</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