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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:15:58+00:00 2026-06-09T13:15:58+00:00

In the method below I’m receiving EXC_BAD_ACCESS on the line containing the urlString variable.

  • 0

In the method below I’m receiving “EXC_BAD_ACCESS” on the line containing the “urlString” variable. My research suggests that this error occurs when the program sends a message to a variable that has already been released. However since I’m using ARC I’m not manually releasing memory. How can I prevent ARC from releasing this variable too soon?

-(NSMutableArray *)fetchImages:(NSInteger *)count {
//prepare URL request
NSString *urlString = [NSString stringWithFormat:@"http://foo.example.com/image?quantity=%@", count];

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString]];

//Perform request and get JSON as a NSData object
NSData *response = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];

//Parse the retrieved JSON to an NSArray
NSError *jsonParsingError = nil;
NSArray *imageFileData = [NSJSONSerialization JSONObjectWithData:response options:0 error:&jsonParsingError];

//Create an Array to store image names

NSMutableArray *imageFileNameArray;

//Iterate through the data
for(int i=0; i<[imageFileData count];i++)
{
    [imageFileNameArray addObject:[imageFileData objectAtIndex:i]];

}

return imageFileNameArray;

}
  • 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-06-09T13:15:59+00:00Added an answer on June 9, 2026 at 1:15 pm

    Your problem has nothing to do with ARC. NSInteger isn’t a class, so you don’t want to be using the %@ format. %@ is going to send a description method to what the system thinks is an object, but when it turns out not to be one – CRASH. To solve your problem, you have two options:

    1. You might want:

      NSString *urlString = 
        [NSString stringWithFormat:@"http://foo.example.com/image?quantity=%d",
              *count];
      

      Make sure the count pointer is valid first!

    2. You might need to change your method signature to be:

      -(NSMutableArray *)fetchImages:(NSInteger)count;
      

      and then change the urlString line as follows:

      NSString *urlString = 
        [NSString stringWithFormat:@"http://foo.example.com/image?quantity=%d", 
            count];
      

      You’ll also need to fix all of the callers to match the new signature.

    The second option seems more “normal” to me, but without more of your program it’s impossible to be more specific.

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

Sidebar

Related Questions

The method below that updates the database is called UpdateHold(). This instance of the
Why does the first method below work? I would have thought that the variable
I have this delegate method below that is setting a few fields in my
I have an error for this method below def mymethod cat = Cat.find_by_cat_id_and_animal_id_and_name(catid, haustierid,
I have this method below that gives me a count of products within a
Hi I have this method below which should insert values into my database. However
The method below works, but it unfortunately, this method involves creating a bitmap the
I have an extension method below, but when I run this, the foreach gives
I am rendering PartialViews/Models with the method below in order to template emails that
The method below is what I want to be done in that thread: public

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.