title: How do I run a method only when app is opened - xcode
body: <p>I am fairly new to xcode so please excuse my lack of knowledge.  I am trying to run a method only when the launch image is shown (or on app startup).  It gets images from a website, but I only need it to do that when the app is opened.  I cannot find any help online how to do that.  Thanks for any help in advance!</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I have this in AppDelegate.m</p>
  
  <pre><code>-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  {
      Home *home=[[Home alloc] init];
      [home getSlideshow];
  
      // Override point for customization after application launch.
      return YES;
  }
  </code></pre>
  
  <p>and this in my Home.m</p>
  
  <p>-(void)getSlideshow{</p>
  
  <pre><code>[self populateStringArray];
  NSString *prefix = @"http://newsongbismarck.com/images/announcements/";
  NSString *suffix = @".jpg";
  
  //NSUInteger count = [imageStringArray count];
  //get this from the website for now
  int number = (int)[imageStringArray count];
  int PageCount = number;
  
  //Setup scroll view
  UIScrollView *Scroller = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 265, 320, 200)];
  Scroller.backgroundColor = [UIColor clearColor];
  Scroller.pagingEnabled = YES;
  Scroller.contentSize = CGSizeMake(PageCount * Scroller.bounds.size.width, Scroller.bounds.size.height);
  
  //Setup Each View Size
  CGRect ViewSize = Scroller.bounds;
  
  int x = PageCount;
  int numb = 0;
  
  UIImageView *ImgArray[PageCount];
  
  
  while(x!=0){
      ImgArray[numb] = [[UIImageView alloc] initWithFrame:ViewSize];
      [ImgArray[numb] setImage:[self getSlideshowImages:[[prefix stringByAppendingString:imageStringArray[numb]]stringByAppendingString:suffix]]];
      [Scroller addSubview:ImgArray[numb]];
  
      //Offset View Size
      ViewSize = CGRectOffset(ViewSize, Scroller.bounds.size.width, 0);
  
      x--;
      numb++;
  }
  
      CGRect newViewSize = Scroller.bounds;
  int NumberOfImages = 21;
  int i;
  for(i=0;i&lt;NumberOfImages;i++){
  
      if(i == 0){
          //Setup first picture
          UIImageView *ImgView = [[UIImageView alloc] initWithFrame:newViewSize];
          NSString *FilePath = [NSString stringWithFormat:@"Page_%d.png", i];
          [ImgView setImage:[UIImage imageNamed:FilePath]];
          [Scroller addSubview:ImgView];
      }else{
          //Setup the rest of the pictures
          newViewSize = CGRectOffset(ViewSize, Scroller.bounds.size.width, 0);
          UIImageView *ImgView = [[UIImageView alloc] initWithFrame:newViewSize];
          NSString *FilePath = [NSString stringWithFormat:@"Page_%d.png", i];
          [ImgView setImage:[UIImage imageNamed:FilePath]];
          [Scroller addSubview:ImgView];
      }
  }
  
      [self.view addSubview:Scroller];
  }
  </code></pre>