Hi I am new to iPhone. What I am doing is sorting the array of images; that array consists of 22 elements. I am writing the code for that:
NSMutableArray *images2 = [[NSMutableArray alloc] initWithArray:images]
int n=22;
for (int i=0;i<n;i++){
for (int j=1;j<n-i;j++){
if(count[j-1]>count[j]){
int t = count[j-1]
count[j-1] = count[j]
count[j] =t ;
NSString *tempimage = [images objectAtIndex:j-1];
[images2 replaceobjectAtIndex:j-1 withobject:[image2 objectAtIndex:j]];
[images2 replaceobjectAtIndex:j withobject:tempimage];
}
}
}
images = [[NSMutableArray alloc] initWithArray:images2];
It sorts finely but at the end it replaces 21st image. What is the wrong in this? If there are any mistakes please post the correct code. What I need is to replace first image to last and second image to first.