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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:17:44+00:00 2026-05-27T18:17:44+00:00

I have a url that is a link to an audio file and will

  • 0

I have a url that is a link to an audio file and will be played using AVFoundation.framework. But for some reason, when the app reaches setting the NSData it crashes. Please help.

NSURL *url = [NSURL URLWithString:songPathForm];
NSData *soundData = [NSData dataWithContentsOfURL:url];

EDIT::::
This is what I did to make it stop crashing, but the data contains nothing

 NSString *url = [songPathForm stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];


                    //NSURL *url = [NSURL URLWithString:songPathForm];
                    NSURLRequest *songRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:url]
                                                              cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60.0];

                NSURLConnection *songConnection = [[NSURLConnection alloc] initWithRequest:songRequest delegate:self];

                if(songConnection)
                {
                    songData = [[NSMutableData data] retain];
                }

It comes out as <>

  • 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-27T18:17:45+00:00Added an answer on May 27, 2026 at 6:17 pm

    There is absolutely no way to answer this question as it is worded, but here are some clues:

    • if there is a crash, there is a backtrace. Post it.

    • if there is a crash, there is some kind of an error. Post it.

    Given that code, there are two failure modes that I can think of:

    • songPathForm is nil or corrupt and/or not an URL.

    • the data at the URL is too large to download and causes the app to attempt to allocate a HUGE amount of memory (there are cases where an allocation can be large enough to crash an app w/o the system jetsam mechanism kicking in).

    There is no crash message, it just freezes and stops responding. url
    is not nil it is…

    Then why did you say your app crashed?!

    dataWithContentsOfURL: is synchronously downloading the contents of whatever is at the URL.

    Thus, you are blocking the main event loop during the download and that is why your app is not responsive.

    You need to asynchronously download the data; i.e. not block the main event loop.

    However that probably won’t entirely fix your problem as it looks like the contents of that URL is really large and, thus, you are likely going to run out of memory if you try to download in memory.

    You either need to download the file to the disk or you need to download only parts of it that you need right now or you need to stream it (if it really is a large audio file as the URL implies).


    The code in your updated question doesn’t make any sense. How do you expect songData to be filled with data from the connection?

    When doing stuff asynchronously, you are basically saying “go do this stuff and let me know every now and then how it is going”. In this case, that’d be a notification that more data is available or that the connection is done reading (or in error).

    You can’t ask for the data immediately because the data isn’t immediately available.

    You’ll want to read through this guide.

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

Sidebar

Related Questions

I have an absolute URL, and the URL that a link on that page
I have a url that contains valid xml, but unsure on how I could
I have a large url that I am encoding using System.Web.HttpUtility.UrlEncode. When I encode
Hi I am using CodeIgniter 1.7.3 framework in my project. I have given URL
I am currently developing an iPhone app that streams audio. The URL I wish
I have url like this which is a js file example like this link
I have a url that I would like to put into my web.config file.
I have a URL that returns a HTTP 302 redirect, and I would like
I have a URL that is shown below: URL is taken out due to
I have a url that looks like that http://example.com/index.php?id=111&title=word1 word2 word3 I need to

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.