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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:50:21+00:00 2026-05-13T15:50:21+00:00

Basic question to which I’m sure there is a simple answer. I’m trying to

  • 0

Basic question to which I’m sure there is a simple answer.

I’m trying to get the timestamp of a photo. When I try to access the NSDateComponents to retrieve a specific date element (say “day” for example), I get a EXC_BAD_ACCESS error.

First, the relevant bits of my code:

// formattedDateString is a string representing the "DateTimeOriginal" EXIF property extracted from the image   
NSDate *takenAt = [[NSDate alloc] initWithString:formattedDateString];
NSLog(@"date: %@", takenAt); // prints= date: 2010-01-10 03:25:00 -0500

NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSLog(@"cal: %@", gregorian); // prints= cal: <__NSCFCalendar: 0x10020b570>

NSUInteger unitFlags =  (NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit);      
NSDateComponents *components = [gregorian components: unitFlags 
                                            fromDate: takenAt
                               ];

int days = [components hour];
NSLog(@"comp: %@", days); // thrown error= Program received signal:  “EXC_BAD_ACCESS”

If I comment out the final line: NSLog(@”comp: %@”, days); the code executes successfully.

I’ve tried a few variants on this but the bottom line is that any time I send a message to components to access a property the “EXC_BAD_ACCESS” error is raised.

The research I did seems to indicate that this is typically the result of an uninitialized pointer or an object that I’ve tried to release that isn’t mine to release. From what I can tell that’s not the case here.

What am I missing?

Thanks in advance for shedding some light on this for me. This is one of my first explorations in Objective-C.

NSDateComponents class reference.

  • 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-13T15:50:22+00:00Added an answer on May 13, 2026 at 3:50 pm

    You are using %@ as the format-specifier for an integer. You need to use %d.

    When you use %@, the NSLog function will treat the argument as an object, and send it the description message. What really happens, is that the runtime tries to dereference the argument (the integer) but because it is not a valid pointer, you get an EXC_BAD_ACCESS exception.

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

Sidebar

Ask A Question

Stats

  • Questions 414k
  • Answers 414k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Very nearly. You'd want to express your update as a… May 15, 2026 at 8:48 am
  • Editorial Team
    Editorial Team added an answer There's this wrapper around HTMLTidy. HTMLTidy allows you to suppress… May 15, 2026 at 8:48 am
  • Editorial Team
    Editorial Team added an answer http://findicons.com is a cool resource for icons. If you're looking… May 15, 2026 at 8:48 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.