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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:01:19+00:00 2026-06-01T05:01:19+00:00

I follow iOS 5 by tutorials book [Newsstand Chapter] , but I have a

  • 0

I follow iOS 5 by tutorials book [Newsstand Chapter] , but I have a problem with updating icon .

As I know newsstand framework has a feature to download contents from an URL and save it to the application directory for example, weather application is terminated or not this method should work , am I right ?

1- Application should download just an icon from my site, while the app is in the background
2- After download the icon file , application should replace my new icon with current icon , which is along with push notification

here is my code but nothing happens !! where should I put this line of code ? in my appDelegate or AppViewController ?

- (void)connectionDidFinishDownloading:(NSURLConnection*)connection destinationURL:(NSURL*)destinationURL {

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    [self saveFile:@"NSIcon" ofType:@"png" fromURL:@"http://website.com/NSIcon.png" inDirectory:documentsDirectory];



UIImage * newsstandImage = [self loadImage:@"NSIcon" ofType:@"png" inDirectory:[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]];

   UIApplication *app = [UIApplication sharedApplication];
    [app setNewsstandIconImage:newsstandImage];

    NSLog(@"downloading...");

}

the sample code is too confusing ! with lots of codes and custom classes or delegates , I would be grateful help me to solve this issue

Thank you

EDITED :

#pragma mark ViewDidLoad 
- (void)viewDidLoad
{


    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://website.com/NSIcon.png"]];
    NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];
    if(conn){
        webData = [NSMutableData data];

        UIApplication *indicator = [UIApplication sharedApplication];
        indicator.networkActivityIndicatorVisible = YES;

        NSLog(@"%@",webData);
    }

}





#pragma mark NewsStand Methods 
-(void) connection:(NSURLConnection *) connection didReceiveResponse:(NSURLResponse *) response 
{

[webData setLength:0];
}


-(void) connection:(NSURLConnection *) connection didReceiveData:(NSData *) data 
{
    NSLog(@"Download Finish");

    UIApplication *indicator = [UIApplication sharedApplication];
    indicator.networkActivityIndicatorVisible = NO;

    [webData appendData:data];
}


-(void) connection:(NSURLConnection *) connection didFailWithError:(NSError *) error 
{
    // inform the user if connection fails//
    NSLog(@"Connection failed! Error - %@ %@",[error localizedDescription],[[error userInfo] objectForKey:NSURLErrorFailingURLStringErrorKey]);



}



- (void)connectionDidFinishDownloading:(NSURLConnection*)connection destinationURL:(NSURL*)destinationURL {

    UIApplication *indicator = [UIApplication sharedApplication];
    indicator.networkActivityIndicatorVisible = NO;

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

    NSString *documentsDirectory = [paths objectAtIndex:0];
    [self saveFile:@"NSIcon" ofType:@"png" fromURL:@"http://website.com/NSIcon.png" inDirectory:documentsDirectory];

    UIImage * newsstandImage = [self loadImage:@"NSIcon" ofType:@"png" inDirectory:[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]];

    UIApplication *app = [UIApplication sharedApplication];
    [app setNewsstandIconImage:newsstandImage];

    NSLog(@"downloading...");

}

2012-04-03 23:35:11.297 iMag[6757:15803] -[__NSCFDictionary setLength:]: unrecognized selector sent to instance 0x85acfd0
(lldb)

  • 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-01T05:01:20+00:00Added an answer on June 1, 2026 at 5:01 am

    connectionDidfinishDownloading is called when you when you create a connection. Example:

    NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];
        if(conn){
            webData = [NSMutableData data];
            [Loading startAnimating];
    
            NSLog(@"%@",webData);
        }
    

    Put these 4 in view controller

    -(void) connection:(NSURLConnection *) connection didReceiveResponse:(NSURLResponse *) response 
        {
            [webData setLength: 0];
        }
    
    
    // This method is responsible for storing the newly received data. The new data is appended to the NSMutableData object created in the button method, or the method that calls NSRUL methods.
    -(void) connection:(NSURLConnection *) connection didReceiveData:(NSData *) data 
    {
        [webData appendData:data];
    }
    
    
    
    
    //If an error is encountered during the download, the delegate receives a connection:didFailWithError: message. The NSError object passed as the parameter specifies the details of the error. It also provides the URL of the request that failed in the user info dictionary using the key NSURLErrorFailingURLStringErrorKey.
    -(void) connection:(NSURLConnection *) connection didFailWithError:(NSError *) error 
    {
        // inform the user if connection fails//
        NSLog(@"Connection failed! Error - %@ %@",[error localizedDescription],[[error userInfo] objectForKey:NSURLErrorFailingURLStringErrorKey]);
    
    
    
    }
    
    
    
    
       //Finally, if the connection succeeds in downloading the request, the delegate receives the connectionDidFinishLoading: message
        - (void)connectionDidFinishDownloading:(NSURLConnection*)connection destinationURL:(NSURL*)destinationURL {
    
    //[webView loadRequest:request];//if you wanted load the website into the webview
    
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    
    
       NSString *documentsDirectory = [paths objectAtIndex:0];
        [self saveFile:@"NSIcon" ofType:@"png" fromURL:@"http://website.com/NSIcon.png" inDirectory:documentsDirectory];
    
    
    
    UIImage * newsstandImage = [self loadImage:@"NSIcon" ofType:@"png" inDirectory:[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]];
    
       UIApplication *app = [UIApplication sharedApplication];
        [app setNewsstandIconImage:newsstandImage];
    
        NSLog(@"downloading...");
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have checked lots of tutorials on xml parsing in iOS .. but most
I know iOS 5.0 has Twitter integration, but what's the fastest way to implement
i'm trying to follow this tutorial here http://ios-blog.co.uk/iphone-development-tutorials/parsing-json-on-ios-with-asihttprequest-and-sbjson/ to do both the ASIHttp and
I'm trying out the new Storyboard feature in iOS 5/XCode, but I can't get
I have tried to follow the upgrade to iOS5 process... but didn't realize that
I'm trying to follow the overlay instructions provided here: https://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/LocationAwarenessPG/AnnotatingMaps/AnnotatingMaps.html#//apple_ref/doc/uid/TP40009497-CH6-SW15+ but the overlay isn't
Follow up to this question . I have the following code: string[] names =
I follow this rule but some of my colleagues disagree with it and argue
I follow the steps in the customdialog example in the documentation, but I get
I'm developing an iOS app with XCode 4.2 and latest SDK. I have added

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.