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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:10:51+00:00 2026-05-21T11:10:51+00:00

I have a NSSet containing many thousands of NSValue objects (wrapping CGPoints ). I

  • 0

I have a NSSet containing many thousands of NSValue objects (wrapping CGPoints). I would like to very quickly find if a given CGPoint value exists in the NSSet. It seems to me that the member: method of an NSSet might do the job here, except that it checks for equality using isEqual:. NSValue objects use isEqualToValue:, and so when I execute the code:

[mySet member:valueToCheck];

it actually causes Xcode to crash.

1) Is there some way to use a custom equality check to make this work for NSValue objects?

2) Is this even the best approach (i.e. is member: quick enough in the first place)? The scenario is that I have a NSSet containing a large number of points representing pixels on the screen (iPad). Later on I need to bombard that set with many thousands of points per second to see if they exist in the set. My approach seems crude for achieving this. I thought about creating something like a huge 2-dimensional bit array, with each index representing a pixel on screen. Once I know the point I’m testing for, I can just jump straight to that point in the array and check for a 1 or 0… does this sound better or worse?

Thanks

  • 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-21T11:10:51+00:00Added an answer on May 21, 2026 at 11:10 am

    Can you get this to a simple reproducible case? For example, I just tried:

    NSValue *v = [NSValue valueWithCGPoint:CGPointMake(1, 1)];
    NSSet *s = [NSSet setWithObject:v];
    NSLog(@"%@", [s member:[NSValue valueWithCGPoint:CGPointMake(1, 1)]]);
    

    But it works just fine.

    edit

    -isEqual: is not the problem:

    NSValue *v1 = [NSValue valueWithPoint:NSMakePoint(1, 1)];
    NSValue *v2 = [NSValue valueWithPoint:NSMakePoint(1, 1)];
    NSLog(@"%d", [v1 isEqual:v2]); //logs "1"
    

    -hash is not the problem:

    NSLog(@"%d", ([v1 hash] == [v2 hash])); //logs "1"
    

    They are different objects:

    NSLog(@"%d", (v1 != v2)); //logs "1"
    

    The problem is in your code. Try cleaning and rebuilding.

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

Sidebar

Related Questions

Suppose I have a function like this: - (NSSet *) someFunction { //code... return
I have an array of objects (Users) each user has an nsset named devices
I have a UIScrollView with only horizontal scrolling allowed, and I would like to
i have one code which moves the uiimage on touch-event it's like this: -(void)touchesBegan:(NSSet
I have subclassed a UIImageView, and have implemented touchesBegan/Moved/Finished like this: - (void)touchesBegan:(NSSet *)touches
I have the following code: - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { NSUInteger touchCount =
I have a crash, and I can't see why it's occurring. I'd like to
Given the following Core Data Model: -> : to-one releationship ->>: to-many relationship Entity
I have an NSMutableArray which has about 18 objects. They are in a specific
I have been using touches began to track as many as 8 touches, and

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.