Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7603175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:36:04+00:00 2026-05-30T23:36:04+00:00

//h file struct runSTRUCT{ NSDate *RunDateTime; } ; //m file struct runSTRUCT run; –

  • 0
//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]; 
}

This all works fine. Then when I click a button and make a string from the date, it gives me EXC_BAD_ACCESS.

-(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]; 
}

When I look in the console and print description, it generally shows 1 of two things:

  1. 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.

  2. Or “run.runDateTime” is some random variable

EDIT: I’m not sure if I put these in the right place because it still doesn’t work(I probably didn’t).

- (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]; 
}

I also have a couple of NSStrings in the struct and they work fine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T23:36:05+00:00Added an answer on May 30, 2026 at 11:36 pm

    You need to retain RunDateTime after you assign/create it from the date formatter.

     [run.RunDateTime retain];
    

    Make sure to release it in your dealloc!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following header file: typedef struct my_data my_data_t; my_data_t* new_my_data(void); void free_my_data(my_data_t*
A foremention, the following is in a header file: typedef struct{ void* userData; }
I have to write an object in to binary file.My struct looks like this.
//file list.h #include stdafx.h namespace st { struct My_List; typedef My_List list; list* create(const
I've declared a struct in my header file like this: typedef struct { NSString
I want to create a struct from data harvested by line from a file.
I have C header file containing the following type definition: // example.h typedef struct
I'm having some trouble with some struct typedef declarations in a header file not
I have a structure defined in my header file: struct video { wchar_t* videoName;
I have the next definition in a file: File: one.h typedef struct example example;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.