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 7619451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:41:26+00:00 2026-05-31T03:41:26+00:00

Ok, so I keep getting a EXC_BAD_ACCESS error which I am guessing is alot

  • 0

Ok, so I keep getting a EXC_BAD_ACCESS error which I am guessing is alot like a seg fault error in C.

My book isn’t real specific on some of these details, so I need some help.

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {

    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    NSDateComponents *comps = [[NSDateComponents alloc ]init];
    [comps setYear:1984];
    [comps setMonth:7];
    [comps setDay:18];
    [comps setHour:0];
    [comps setMinute:0];
    [comps setSecond:0];

    NSCalendar *g =[[NSCalendar alloc ]init];
    NSDate *dateofbirth = [g dateFromComponents:comps];
    NSDate *now = [NSDate date];

    double timeSince = [now timeIntervalSinceDate:dateofbirth ];


    NSLog(@"your age %@", timeSince);



    [pool drain];



    return 0;
}

I think I am running into trouble because I am initializing and allocating memory within the pool. Is this correct?

  • 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-31T03:41:27+00:00Added an answer on May 31, 2026 at 3:41 am

    The “%@” in your NSLog string expects an object, but you have passed in a double. Try:

        NSLog(@"your age %lf", timeSince);
    

    Specifically, “%@” tries to call -message on the argument. Since your argument is a double, the runtime is ultimately trying to treat the double as a pointer, and dereference it (resulting in your EXC_BAD_ACCESS).

    As far as memory management is concerned, you are leaking comps and g. At the end of the program, add a:

    [comps release];
    [g release];
    

    Although this isn’t causing your error (nor is it really harming anything, as you are exiting and the OS is reclaiming the memory. As you learn Objective-C, however, not releasing your objects in other places will result in leaks)

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

Sidebar

Related Questions

I keep getting the following error: 'function' object has no attribute 'objects' for Like.
I keep getting some weird error in Processing, using the following tiny piece of
I keep getting this error when I try to build my project which uses
I keep getting this error, and I'm not really sure why this isn't working
I keep getting a exc bad access error and I think it has something
I keep getting a -> Program received signal: EXC_BAD_ACCESS. In the following code but
Keep getting this error after inserting a subdatasheet into a query and trying to
Keep getting the error Arguments are not sufficiently instantiated for the multiplication by addition
I keep getting this error: System.Runtime.InteropServices.COMException was thrown on C:\Users\---\documents\visual studio 2010\Projects\TBrowser\TBrowser\TBrowserWindow.xaml: Error HRESULT
I keep getting this error below, and each time I need to delete the

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.