How to display (5 or 7 or 8 etc) images from 25 images randomly without repetition from array in iphone
<p>In my <code>FirstViewcontroller</code> I have picker containing <code>1</code> to <code>25</code> values, if the user select 5 in the picker on the next screen it should display 5 images randomly out of 25 images without repetition of that 5 images. If user selects another number means it takes that number as input and it should display images according to that number. If I run my code means every time it showing all 25 images not selected number images. Here is my code </p>

<pre><code>- (void)viewDidLoad {    
    myImageNames = [[NSMutableArray alloc] init];

    [myImageNames addObject:[UIImage imageNamed:@"Red.png"]];
    [myImageNames addObject:[UIImage imageNamed:@"Blue.png"]];
    [myImageNames addObject:[UIImage imageNamed:@"LightRed.png"]];
    [myImageNames addObject:[UIImage imageNamed:@"Orange.png"]];
    .
    .
    .

    timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self  selector:@selector(ChangingImgView:) userInfo:nil repeats:YES];
}

- (void) ChangingImgView:(int)selectedNumberFromPicker {
    selectedNumberFromPicker = [num intValue];

    for (int i=0; i &lt; selectedNumberFromPicker; i++) {

        index = arc4random() % 25;
        NSString *strIndex = [NSString stringWithFormat:@"%i",index];
        [myImageNames addObject:strIndex];
        imgBtn = [UIButton buttonWithType:UIButtonTypeCustom];

        imgBtn.frame = CGRectMake(250, 300, 170, 220);
        UIImage *img = [myImageNames objectAtIndex:index];
        [imgBtn setBackgroundImage:img forState:UIControlStateNormal];
        [imgBtn addTarget:self action:@selector(ClickingOnImage) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:imgBtn];
    }
}
</code></pre>

<p>Please help me.</p>
