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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:52:12+00:00 2026-05-13T17:52:12+00:00

I have 2 arrays. One is a large static group of 600 objects, the

  • 0

I have 2 arrays. One is a large static group of 600 objects, the other is a small varying group of 10 objects.

I want to take any common objects between the two groups and put them in a new array.

So lets say the large group contains 600 objects named 1 to 600. The smaller group contains 9 objects: 1, 2, 3, 4, 5, 6, a, b, c. I want to be able to create a new array that contains the objects 1, 2, 3, 4, 5, 6.

What is the best way to do this?

  • 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-13T17:52:12+00:00Added an answer on May 13, 2026 at 5:52 pm

    Are you sure that you need NSArrays? For intersections it would be better to use NSSets. For more information about the usage of NSArrays and NSSet please refer to Cocoa with Love: NSArray or NSSet, NSDictionary or NSMapTable.

    If you are using NSSet you have to create a new NSMutableSet, which has the method intersectSet:, which can be used for your purpose:

    NSMutableSet *set1 = [[NSMutableSet alloc] initWithObjects:@"0", @"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", nil];
    NSMutableSet *set2 = [[NSMutableSet alloc] initWithObjects:@"2", @"4", @"6", @"8", @"10", @"12", @"14", @"18", nil];
    
    NSLog(@"set1: %@", set1);
    NSLog(@"set2: %@", set2);
    [set1 intersectSet:set2];
    NSLog(@"isec: %@", set1);
    

    You can create a NSMutableSet from an NSArray using the addObjectsFromArray: method:

    NSArray *array = [[NSArray alloc] initWithObjects:@"1", @"2", nil];
    NSMutableSet *set = [[NSMutableSet alloc] init];
    [set addObjectsFromArray:array];
    

    It may be that you can also filter the NSArray using the filterUsingPredicate: method, however I have never worked with NSPredicates therefore this is only an assumption.

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

Sidebar

Related Questions

I have two arrays, one is very large (more than million entries) and other
I have 2 arrays, I want to remove the one from the other. I
Say I have two arrays where one is a permutation of the other: A
I have a program which needs to turn many large one-dimensional numpy arrays of
I have these 2 fairly large arrays, one with pointers and one with strings
I have two arrays the first one has this structure Parameter Keys array array
I have some Javascript code that creates 2 arrays: One for Product Category and
I have two arrays. I'd like to merge them into one, but remove the
I have 2 arrays that I would like to render in a template, one
I have two arrays of data that I'm trying to amalgamate. One contains actual

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.