title: Too many open files iOS
body: <p>i am new on ios programming, when my app is running , i am taking these errors. I am loading 950+ images in my app and i am using ARC.</p>
  
  <blockquote>
    <p>ImageIO: CGImageRead_mapData 'open' failed '/Users/apple/Library/Application Support/iPhone Simulator/6.1/Applications/16551664-4694-4742-85DC-2C3C0ADC5289/demo.app/menu-24-20.png'error = 24 (Too many open files)</p>
    
    <p>ImageIO: CGImageRead_mapData 'open' failed '/Users/apple/Library/Application Support/iPhone Simulator/6.1/Applications/16551664-4694-4742-85DC-2C3C0ADC5289/demo.app/menu-24-20.png'error = 24 (Too many open files)</p>
    
    <p>ImageIO: CGImageRead_mapData 'open' failed '/Users/apple/Library/Application Support/iPhone Simulator/6.1/Applications/16551664-4694-4742-85DC-2C3C0ADC5289/demo.app/circle_green.png'
             error = 24 (Too many open files)</p>
    
    <p>ImageIO: CGImageRead_mapData 'open' failed '/Users/apple/Library/Application Support/iPhone Simulator/6.1/Applications/16551664-4694-4742-85DC-2C3C0ADC5289/demo.app/circle_green.png'
             error = 24 (Too many open files)</p>
    
    <p>ImageIO: CGImageRead_mapData 'open' failed '/Users/apple/Library/Application Support/iPhone Simulator/6.1/Applications/16551664-4694-4742-85DC-2C3C0ADC5289/demo.app/shopping_cart_1-512.png'
             error = 24 (Too many open files)</p>
    
    <p>ImageIO: CGImageRead_mapData 'open' failed '/Users/apple/Library/Application Support/iPhone Simulator/6.1/Applications/16551664-4694-4742-85DC-2C3C0ADC5289/demo.app/shopping_cart_1-512.png'
             error = 24 (Too many open files)</p>
  </blockquote>
  
  <p>This code block is part of my app.</p>
  
  <pre><code>                while(sqlite3_step(compiledStatement) == SQLITE_ROW)  {
                      int UrunId = sqlite3_column_int(compiledStatement,0);
                      //NSString *urunNo= [NSString stringWithFormat:@"%i",UrunId];
                      UrunAdi = [NSString stringWithUTF8String:(char*)sqlite3_column_text(compiledStatement, 1)];
                      NSString *imageName= [NSString stringWithUTF8String:(char*)sqlite3_column_text(compiledStatement, 2)];
                      UIImageView *background = [[UIImageView alloc]initWithFrame:CGRectMake(column*197+30, row*350, 175, 280)];
  
                      NSString *filePathBackGround = [[NSBundle mainBundle] pathForResource:@"BackImage" ofType:@"png"];
                      NSData *myData = [NSData dataWithContentsOfFile:filePathBackGround];                        
                      UIImage *blackBackGround = [UIImage imageWithData:myData];
  
                      [background setImage:blackBackGround];                                            
                      [scrollView addSubview:background];
  
  
  
                      NSString *filePathSepeteEkleButton = [[NSBundle mainBundle] pathForResource:@"sepeteEkleButtonImage" ofType:@"png"];
                      NSData *myDataButton = [NSData dataWithContentsOfFile:filePathSepeteEkleButton];
  
                      UIImage *sepeteEkleButtonImage = [UIImage imageWithData:myDataButton];
                      UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
                      [button setFrame:CGRectMake(column*197+38 , row*350+8, 159, 45)];
                      [button setImage:sepeteEkleButtonImage forState:UIControlStateNormal];
                      [button addTarget:self
                                 action:@selector(addToChart:)
                       forControlEvents:UIControlEventTouchUpInside];
                      button.tag = UrunId;
  
  
  
                      UILabel *buttonLabel=[[UILabel alloc]initWithFrame:CGRectMake(column*197+43,row*350+20,200,20)];
                      buttonLabel.textColor = [UIColor whiteColor];
                      buttonLabel.backgroundColor=[UIColor clearColor];
                      buttonLabel.text=UrunAdi;
  
                      [scrollView addSubview:button];
  
                      [scrollView addSubview:buttonLabel];
  
  
                      NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
                      NSString *documentsPath = [paths objectAtIndex:0]; //Get the docs directory
                      NSString *filePath = [documentsPath stringByAppendingPathComponent:imageName];
  
                      NSData *pngData = [NSData dataWithContentsOfFile:filePath];
                      if (pngData == nil) {
                          NSString *filePathResimYok= [[NSBundle mainBundle] pathForResource:@"resimYok" ofType:@"jpeg"];
                          NSData *myDataResimYok= [NSData dataWithContentsOfFile:filePathResimYok];
                          image2 = [UIImage imageWithData:myDataResimYok];//horoda
                      }else{
                          image2 = [UIImage imageWithData:pngData];
                      }
                      image2=[image2 imageByScalingAndCroppingForSize:CGSizeMake(175, 210)];
  
                      //UIImage *urunDetayImage = [UIImage imageNamed:image2];
                      UIButton * urunDetayButton = [UIButton buttonWithType:UIButtonTypeCustom];
                      [urunDetayButton setFrame:CGRectMake(column*197+38 , row*350+58, 159, 170)];
                      [urunDetayButton setImage:image2 forState:UIControlStateNormal];
                      [urunDetayButton addTarget:self
                                          action:@selector(buttonClicked:)
                                forControlEvents:UIControlEventTouchUpInside];
                      urunDetayButton.tag = UrunId;
                      [scrollView addSubview:urunDetayButton];
  
                      UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(column*197+38,row*350+245,200,20)];
                      label.textColor = [UIColor whiteColor];
                      label.backgroundColor=[UIColor clearColor];
                      label.text=UrunAdi;
                      [scrollView addSubview:label];
  </code></pre>
  
  <p>I am trying to fix for 3 days.Please help me. Thanks.</p>