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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:12:08+00:00 2026-06-01T08:12:08+00:00

Hi I was wondering how can I call a method just for one time

  • 0

Hi I was wondering how can I call a method just for one time in application life … My application should download some files from server and I need do it just for one time; I mean mean just one time per installation

here is my method

//Download some images from server and save it into directory 

- (void) downloadCovers {

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

}

and this method set images as UIButton BG :

  - (void)buttonsBGImage {

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

        [mag1 setBackgroundImage:bgMag1 forState:UIControlStateNormal];
         NSLog(@"BG IS SET");

    }
  • 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-01T08:12:09+00:00Added an answer on June 1, 2026 at 8:12 am

    Set a flag as a NSUserDefaults key and check for this NSUserDefault value in your downloadCovers method. If it is already set, do nothing, else download files and set the flag to true.

    Like so:

    -(void) downloadCovers {
    BOOL downloaded = [[NSUserDefaults standardUserDefaults] boolForKey: @"downloaded"];
    if (!downloaded) {
         //download code here
          [[NSUserDefaults standardUserDefaults] setBool:YES forKey: @"downloaded"];
        }
    }
    

    Cheers

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

Sidebar

Related Questions

I was wondering how can I programmatically copy all the discussion items from one
I'm just wondering..is it possible to receive multiple responses from a single ajax call?
UIView has a setNeedsDisplay method that one can call several times within the same
I was wondering how can I redirect from /news to /news/ in a google
I have two separate installs of WebSphere. (Actually one is WebSphere Application Server V6.1
Just wondering, Would the SqlConnection be diposed/closed when this method is done? Or do
I'm just wondering if somebody can explain to me how to pass reference cells
Just found this code-snippet in our application. I am wondering if the first line
I was wondering how can I list the user tables name with its primary
I am wondering how can I hide/remove a tag after a certain amount of

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.