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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:23:47+00:00 2026-05-30T22:23:47+00:00

Is it possible to subtract the values in one NSMutableArray from those in another

  • 0

Is it possible to subtract the values in one NSMutableArray from those in another NSMutableArray, while preserving any remaining like values (keep duplicate copies)? I don’t want to remove every instance of the value, just a 1 for 1 subtraction.

I’m working with CGPoints.

Array1
ccp(1,1)
ccp(1,1)
ccp(1,2)
ccp(1,3)

Array2
ccp(1,1)

Desired output: Array3
ccp(1,1)
ccp(1,2)
ccp(1,3)

  • 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-30T22:23:49+00:00Added an answer on May 30, 2026 at 10:23 pm

    Sorry I didn’t understand your question properly before. Maybe you could try something like:

    NSMutableArray *points1 = [NSMutableArray arrayWithObjects:
                                [NSValue valueWithCGPoint:CGPointMake(1, 1)],
                                [NSValue valueWithCGPoint:CGPointMake(1, 1)],
                                [NSValue valueWithCGPoint:CGPointMake(1, 2)],
                                [NSValue valueWithCGPoint:CGPointMake(1, 3)], nil];
    
    NSArray        *points2 = [NSArray arrayWithObject:
                                [NSValue valueWithCGPoint:CGPointMake(1, 1)]];
    
    NSInteger index = NSNotFound;
    
    for (NSValue *point in points2) {
        index = [points1 indexOfObject:point];
    
        if (NSNotFound != index) {
            [points1 removeObjectAtIndex:index];
        }
    }
    
    NSLog(@"%@", points1);
    
    => 2012-03-04 00:02:26.376 foobar[19053:f803] (
           "NSPoint: {1, 1}",
           "NSPoint: {1, 2}",
           "NSPoint: {1, 3}"
       )
    

    Update

    NSNotFound is defined in NSObjCRuntime.h. You can find this out by command + clicking on the symbol NSNotFound in Xcode.

    The definition is

     enum {NSNotFound = NSIntegerMax};
    

    The reason I knew to use this is by looking at the NSArray documentation for the indexOfObject: method, which reads:

    Return Value
    The lowest index whose corresponding array value is equal to anObject. If none of the objects in the array is equal to anObject, returns NSNotFound.

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

Sidebar

Related Questions

Is it possible to subtract one DateTime from another and get the result in
Possible Duplicate: NAnt or MSBuild, which one to choose and when? What is the
Possible Duplicate: How do you send email from a Java app using Gmail? How
Possible Duplicate: Singleton: How should it be used Following on from Ewan Makepeace 's
Is it possible to subtract time from a calendar? e.g. ..... Calendar DueTime =
Possible Duplicate: Anyone know a simple way using java calendar to subtract X days
Possible Duplicate: Anyone know a simple way using java calendar to subtract X days
Possible Duplicates: How to subtract a vector from each row of a matrix? How
Possible Duplicate: PHP calculate age I'm trying to subtract the years and check the
Possible Duplicate: Why not use tables for layout in HTML? Under what conditions should

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.