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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:47:35+00:00 2026-05-28T22:47:35+00:00

In the app I’m writing, NSDate *test = [NSDate distantPast]; [test retain]; // crashes

  • 0

In the app I’m writing,

        NSDate *test = [NSDate distantPast];
        [test retain]; // crashes with EXC_BAD_ACCESS

crashes almost every time on retain, while

        NSDate *test = [NSDate date];
        [test retain];

does never.

I am puzzled why. The piece of code is called on the main thread through an UI action and I’m running it in the IOS simulator in the debugger. Sometimes it works without crashing. Might it be a concurrency issue? Is there an obvious problem that I am missing or should I try trimming down my application until it works?

UPDATE:

        NSDate *test = [[NSDate distantPast] copy];

crashes as well, while

        NSDate *test = [[NSDate date] copy];

doesn’t. Cleaning the build and restarting the IOS simulator didn’t help either.

UPDATE 2:

Calling the snippet in application:didFinishLaunchingWithOptions does not crash. My app must be doing something that messes up the system. I’ll post an answer when I find out what.

UPDATE 3 (SOLVED):

The offending line was somewhere completely different in my application:

WRONG:

- (id)init
{
    lastUpdate = [NSDate distantPast];
}

The instance of distantPast gets autoreleased after the execution leaves the init code block. I should have retained it to counter that autorelease.

CORRECT:

- (id)init
{
    lastUpdate = [[NSDate distantPast] retain];
}
  • 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-28T22:47:35+00:00Added an answer on May 28, 2026 at 10:47 pm

    Profile your app with the “Zombies” instrument. When it crashes, you should be able to see the full retain/release history of the rogue object, and from that figure out what went wrong.

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

Sidebar

Related Questions

An app I'm writing always crashes on a clients computer, but I don't get
My app crashes, but generates no exception in the console and no crash log
app.yaml application: cloudymovie version: 1 runtime: java welcome_files: - test.jsp handlers: - url: /test/*
App Store We have been developing an app for quite some time now for
App crashes after execution of cellForRowAtIndexPath method of tableView It goes into: UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:]
My app, which uses ARC, does the following: Uploads a picture taken by the
app crashes when pressing back button log description:- [FootballScoreBoardViewController bannerViewDidLoadAd:]: message sent to deallocated
The app I am writing deals with utility service addresses, and right now I
I am writing an app with both english and french support. The app requests
App Engine only allows you to use these formats for XMPP addresses: app-id@appspot.com anything@app-id.appspotchat.com

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.