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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:43:09+00:00 2026-05-25T20:43:09+00:00

NSArray *t_annos; @try { NSLog(@ — pointer before = %ld — , (long) t_annos);

  • 0
NSArray *t_annos;

@try 
{
  NSLog(@" --- pointer before = %ld --- ", (long) t_annos);  
  t_annos 
     = [NSKeyedUnarchiver unarchiveObjectWithFile : d_path]; 
  NSLog(@" --- pointer after  = %ld --- ", (long) t_annos);
}
@catch (NSException *e) 
{
  NSLog(@" --- e caught  ---"); 
  t_annos = nil;     
}

Please consider the above statements, the situation is :

1

According to documentation, an exception should be raised if d_path does not point to a valid archive. But no exception is caught even if d_path is deliberately set with an invalid path.

2

Have tested the code on both the xcode simulator and a test devise (iphone). Although both the simulator and the phone devise do not catch any exceptions, the phone unarchives the array as expected while on the simulator the program stops with an output : “Program received signal : “EXC_BAD_ACCESS”” at the Debugger Console.

3

The “bad access” error should have come at the “unarchiveObjectWithFile” statement since the program stops after the first NSLog output.

4

When try with a single NSString object archived and unarchive, both the simulator and the test device have no problem. But there is still no exception caught even when the path is wrong.

There may be something missing on my part, hope that somebody knowledgable can help.

  • 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-25T20:43:10+00:00Added an answer on May 25, 2026 at 8:43 pm

    According to the documentation, the exception is thrown only when there exists a file at the path and is not an archive created by NSKeyedArchiver.

    unarchiveObjectWithFile:

    Decodes and returns the object graph previously encoded by
    NSKeyedArchiver written to the file at a given path.
    + (id)unarchiveObjectWithFile:(NSString *)path

    Parameters: path

    A path to a file that contains an object graph previously encoded by
    NSKeyedArchiver.

    Return Value

    The object graph previously encoded by NSKeyedArchiver written to the
    file path. Returns nil if there is no file at path.

    Discussion

    This method raises an NSInvalidArgumentException if the file at path
    does not contain a valid archive.

    So, for –

    1: Most likely the invalid path that you set is not pointing to any file, and hence the return value is nil without any exception.

    2: Have you ensured the path on the simulator points to a valid file archived by NSKeyedArchiver earlier? Most likely, it points to some other file.

    4: Same thing as #1.

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

Sidebar

Related Questions

Why doesn't this work? - (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views { if (TRACE_LOG) NSLog(@%s, __FUNCTION__);
If I have my data in an NSArray, and I can NSLog that data
i am using NSArray named as allAvailableServices . first i initialize it and after
NSArray *subviewsList = [[NSArray alloc] initWithArray:[self.view subviews]]; for (UIView *aView in subviewsList) { NSLog(@%@,subviewsList);
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *myPlistPath =
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [path objectAtIndex:0]; NSString *databasePath =
I have an NSArray and I'd like to create a new NSArray with objects
Given an NSArray of NSStrings, is there a quick way to join them together
I have an NSArray of Foos in an Objective-C program. I would like to
How to convert NSArray into NSString in objective-c?

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.