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

  • SEARCH
  • Home
  • 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 8854243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:50:21+00:00 2026-06-14T13:50:21+00:00

I am attempting to use this array cleaning method, and there seems to be

  • 0

I am attempting to use this array cleaning method, and there seems to be an error. I can’t spot it, I know the array goes in with 3116 items, comes out with 3116 (and I know for a fact there are three duplicates.

Please advice, thanks!

-(NSArray*) removeDuplicates:(NSArray*)inputArray{
NSMutableArray *arrayToClean = [NSMutableArray arrayWithArray:inputArray];
for (int i =0; i<[arrayToClean count]; i++) {

    for (int j=(i+1); j < [arrayToClean count]; j++) {
        if ([[arrayToClean objectAtIndex:i] isEqual:[arrayToClean
                                                     objectAtIndex:j]]) {
            [arrayToClean removeObjectAtIndex:j];
            j--;

        }

    }
}
NSArray *arrayToReturn = [NSArray arrayWithArray:arrayToClean];
return arrayToReturn;

}

  • 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-14T13:50:22+00:00Added an answer on June 14, 2026 at 1:50 pm

    NSSet will make this a lot easier:

    -(NSArray *)removeDuplicates:(NSArray *)inputArray {
        NSSet *unique = [NSSet setWithArray:inputArray];
    
        return [unique allObjects];
    }
    

    Please note that a set has no guaranteed order. If you need the objects in the array to be in a specific order then you should sort the resulting array as needed.

    It may also be appropriate to use an NSSet instead of the original array, then you don’t need to worry about duplicates at all. But this depends on the other needs of your array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Attempting to use the data series from this example no longer passes the JSONLint
I'm attempting to use code I've found that uses Win32. However, I'm getting this
I am attempting to use livequery. I unfortunately am stuck using jquery 1.2.6. This
I am attempting to compress a string via use of zlib (I've tried this
I'm currently passing an array to a function, then attempting to use glGenBuffers with
I am attempting to use the android NDK. Is there a way to return
I am attempting to use a recursive function to search through a multidimensional array,
I am attempting to use a foreach to output the array below. I have
I am attempting to use JSONP to return an array from PHP to JavaScript.
below is what I'm attempting to use for my site, this php page shows

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.