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

  • Home
  • SEARCH
  • 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 6719829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:08:20+00:00 2026-05-26T09:08:20+00:00

I have the following code: NSArray *array = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:nil]; NSString *temp;

  • 0

I have the following code:

NSArray *array = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:nil];

NSString *temp;
for (int i = 0; i < [array count]; i++)
{
    temp = [array objectAtIndex:i];
    NSLog(@"temp length = %@", [temp length]);
}

I get an EXC_BAD_ACCESS error at the NSLog line. I assume it’s erring out at the [temp length] bit. The weird thing is, I can do other methods of NSString on temp and they work fine, like [temp characterAtIndex:0].

I’ve also tried doing [[array objectAtIndex:i] retain];, but that doesn’t seem to help.

Does anyone know why I’m getting this error?


EDIT: Turns out it was crashing at the NSLog because it was %@ instead of %lu. The real problem was with other code that I had omitted from this post. After playing around with it some more, I got it working.

  • 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-26T09:08:21+00:00Added an answer on May 26, 2026 at 9:08 am

    From my understanding, the “%@” placeholder is for object pointers, “length” returns “NSUInteger” which is not a pointer. Try “%lu” instead of “%@”.

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

Sidebar

Related Questions

I have successfully created video from images using the following code -(void)writeImageAsMovie:(NSArray *)array toPath:(NSString*)path
I have the following code in a method of my app: NSArray *array =
I have the following code and am getting error at NSString *weight line: *
I have the following code: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory =
I have the following code which fetches a string from an array of strings
I have the following code which is producing this error. I cannot understand why
Suppose I have the following code: ... var data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil]; NSLog.trace(@getdData:
I have the following code that decodes a JSON string into an array of
How is an array saved to NSUserDefaults? I have the following code which tries
So I have the following code: - (void)addSupportLinksMenuItems { NSString *subMenuTitle; NSString *getURL; if

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.