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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:18:28+00:00 2026-05-16T04:18:28+00:00

Hi I am new to iPhone. What I am doing is sorting the array

  • 0

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.

  • 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-05-16T04:18:29+00:00Added an answer on May 16, 2026 at 4:18 am

    Solution to your problem: don’t implement sorting yourself, let the framework do it for you. NSMutableArray has a number of sorting methods that will do all this stuff for you. If you can clarify a few points (see the comments on your question) we can help you construct the proper sorting method call.

    – exchangeObjectAtIndex:withObjectAtIndex:
    – sortUsingDescriptors:
    – sortUsingComparator:
    – sortWithOptions:usingComparator:
    – sortUsingFunction:context:
    – sortUsingSelector:
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hi i am new to iphone. what i am doing is displaying 20 images
I have a new iPhone app that has the following (and only the following)
I'm pretty new to iPhone application development and I'm doing well so far. But
I'm new to iPhone development, and doing some experimentation with Core Animation. I've run
hi i am new to iphone. what i am doing is cretating a imageview
hi i am new to iphone. what i am doing is creating two classes
hi i am new to iphone. what i am doing is placing a button
When building a new iPhone app in Xcode, I'm getting this error: codesign error:
I'm new to iPhone and Apple development and working on my first application. It
I'm new to iPhone development, and multiple views (xib or nib) are really confusing

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.