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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:16:39+00:00 2026-05-24T01:16:39+00:00

SOLVED: the filename was an autoreleased string no longer available when called at createFileAtPath:

  • 0

SOLVED: the filename was an autoreleased string no longer available when called at createFileAtPath:


I’m trying to track the progress of the download of a file and the code I’m trying to implement is this (edited):

 connection = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];

    if (connection)
        receivedData = [[NSMutableData data] retain];    

    -(void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
    [receivedData setLength:0];

    totalBytes = [[NSNumber numberWithLongLong:[response expectedContentLength]] intValue];
    NSLog(@"content-length: %i bytes", totalBytes);
}

-(void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    [receivedData appendData:data];

    int resourceLength = [[NSNumber numberWithUnsignedInteger:[receivedData length]] intValue];
    NSLog(@"receivedData length: %i", resourceLength);
}

-(void) connectionDidFinishLoading:(NSURLConnection *)connection
{
    [fileMgr createFileAtPath:filename contents:receivedData attributes:nil];

    //if instead i write only the Apple example:
    //NSLog(@"Succeeded! Received %d bytes of data",[receivedData length]);
    //there's no SIGABRT
    [receivedData release];
    [connection release];
}

but the createFileAtPath:contents:attributes: just gives SIGABRT:

-[__NSCFData
getFileSystemRepresentation:maxLength:]:
unrecognized selector sent to instance
0x2ba510

* Terminating app due to uncaught exception
‘NSInvalidArgumentException’, reason:
‘-[__NSCFData
getFileSystemRepresentation:maxLength:]:
unrecognized selector sent to instance
0x2ba510’

what am i doing wrong? isn’t this the way to download a file asynchronously ?

2 more things: a) the content-length NSLog is correct. b) if I don’t initWithCapacity:content-lenght in didReceiveResponse and just init, the receivedData length only grows about two times the content-length…

  • 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-24T01:16:40+00:00Added an answer on May 24, 2026 at 1:16 am

    SOLVED: the filename was an autoreleased string no longer available when called at createFileAtPath:

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

Sidebar

Related Questions

i need to get filename from file path string. For example, from this string
public static List<Product> Load(string filename) { if (!File.Exists(filename)) { throw new FileNotFoundException(Data could not
SOLVED. Code has been edited to reflect solution. Given the following GridView : <asp:GridView
Update: Solved, with code I got it working, see my answer below for the
I'm trying to edit a text file to remove the vowels from it and
I am trying to load a *.wav file to a byte array using C#
I have the following code: except(OSError) as (errno, strerror, filename): print OSError [%d]: %s
I solved this question my own. The filename was wrong lolz. Hello everyone! I'm
solved I changed the bfs::directory_iterator Queue to a std::string queue, and surprisingly solved the
FILE *fd; if (fd=fopen(fileName,r) == NULL) { printf(File failed to open); exit(1); } This

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.