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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:39:50+00:00 2026-06-04T09:39:50+00:00

So I have three different arrays involved here… I’m looping through golferThreeIcons (NSMutableArray), and

  • 0

So I have three different arrays involved here…

I’m looping through golferThreeIcons (NSMutableArray), and I’m trying to take the highest 4 results (golferThreeIcons contains #’s as strings) and store them into the topFourIconsNum (NSMutableArray) and then I plan to store the id of that highest number in the array topFourIconsId (NSMutableArray).

One tricky thing is that golferThreeIcons start out at 99, but I want that to act like zero. So the number 99 should not get added to either of the arrays…

Example:
golferThreeIcons {2,1,5,3,9}

And after the loop went through I want it to show something like this…

topFourIconsId {0,2,3,4} — 0 corresponds to 2 in golferThreeIcons — 2 corresponds to 5 in golfer three icons

topFourIconsNum {2,5,3,9} —-(in any order as long as it corresponds to the top four icons id)

NSMutableArray *topFourIconsId = [NSMutableArray arrayWithObjects: @"0", @"0", @"0", @"0", @"0" ,nil];
NSMutableArray *topFourIconsNum = [NSMutableArray arrayWithObjects: @"0", @"0", @"0", @"0", @"0" ,nil];
int *ids = 0;
                for (NSString *s in golferThreeIconCounter) {
                    if(s != @"0") {
                        int sint = [s intValue];
                        int *idn = 0;
                        for(NSString *n in topFourIconsNum) {
                            int nint= [n intValue];
                            if(sint == 99 && nint == 0) {
                                NSString *idstring = [NSString stringWithFormat:@"%d", ids];
                                NSString *sintstring = [NSString stringWithFormat:@"%d", sint];
                                [topFourIconsId replaceObjectAtIndex:idn withObject:idstring];
                                [topFourIconsNum replaceObjectAtIndex:idn withObject:sintstring];
                                NSLog(@"IN %@",sintstring);
                                break;
                            }
                            else {
                                if (sint > nint) {
                                    NSString *idstring = [NSString stringWithFormat:@"%d", ids];
                                    NSString *sintstring = [NSString stringWithFormat:@"%d", sint];
                                    [topFourIconsId replaceObjectAtIndex:idn withObject:idstring];
                                    [topFourIconsNum replaceObjectAtIndex:idn withObject:sintstring];
                                    NSLog(@"IN %@",sintstring);
                                    break;
                                }
                            }
                            idn++;
                        }
                    }
                    ids++;
                }
  • 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-06-04T09:39:52+00:00Added an answer on June 4, 2026 at 9:39 am

    Just a crazy idea

    Put your golferThreeIcons in a NSDictionary with the array index as the key and the array value as the value and then sort the keys on their value:

    NSDictionary *dict = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"2", @"1", @"5", @"3", @"9", nil] forKeys:[NSArray arrayWithObjects:@"0", @"1", @"2", @"3", @"4", nil]];
    NSArray *sortedKeys = [dict keysSortedByValueUsingSelector:@selector(caseInsensitiveCompare:)];
    
    NSLog([sortedKeys description]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

iSo let's say I have three different arrays of objects, and I want to
I have three different configurations on my project, all three do not require all
I have three different development machines. Do I need three different iPhone Developer Program
I'm playing with a GWT/GAE project which will have three different pages, although it
I have three radio buttons with same name and different values.When I click the
I have a table that has three different date columns, so I set each
I have an Android project that branched into three different applications, app-1 , app-2
I have a rails application that has three different types of users and I
Task at hand — I have three versions of some code, developed by different
So, I have three numpy arrays which store latitude, longitude, and some property value

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.