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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:11:32+00:00 2026-06-05T07:11:32+00:00

I am trying to get the compare an object in an NSArray with two

  • 0

I am trying to get the compare an object in an NSArray with two objects in two different NSArrays and i want to store the first occurence of the object and discard the next.

e.g:-

I have an Array1 where it contains objects like (20.12, 20.15, 21.4, 22.6, 23.0, 24.2, 28.7, 30.5, 30.9, 32.6, 33.7).
Now i have another Array2 that contains objects like (20.00, 22.0, 28.0, 30.0, 33.0) and another Array3 that contains objects like (21.0, 24.0, 29.0, 32.0, 34.0)

Now i want to store the first objects that are in between (20.00 – 21.0, 22.0 – 24.0, 28.0 – 29.0, 30.0 – 32.0, 33.0 – 34.0). I have tried to implement this by using

if (clickTimeInterval >= [[Array2 objectAtIndex:i] doubleValue] && clickTimeInterval <= [[Array3 objectAtIndex:i] doubleValue]) {

My clickTimeInterval is the time interval stored in my Array1. I am able to get the values but i just want to store the values that comes first and store into Array4. It looks something like Array4 = (20.12, 22.6, 24.2, 28.7, 30.5, 33.7). Can anyone please help me out on how to get 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-06-05T07:11:33+00:00Added an answer on June 5, 2026 at 7:11 am

    It depends on how optimized you want to be. Here’s a version that re-samples “Array1” for each range. If you have a large number of objects to filter (and they are sorted), you could store the last found location to make subsequent searches quicker.

    - (NSArray *)bucketTest {
        NSMutableArray *result = [NSMutableArray array];
    
        NSArray *samples = [NSArray arrayWithObjects:[NSNumber numberWithDouble:1.1], [NSNumber numberWithDouble:1.5], [NSNumber numberWithDouble:2.2], nil];
        NSArray *lows = [NSArray arrayWithObjects:[NSNumber numberWithDouble:1.0], [NSNumber numberWithDouble:2.0], nil];
        NSArray *highs = [NSArray arrayWithObjects:[NSNumber numberWithDouble:2.0], [NSNumber numberWithDouble:3.0], nil];
        for (int bucket = 0; bucket < [lows count]; bucket++) {
            double low = [[lows objectAtIndex:bucket] doubleValue];
            double high = [[highs objectAtIndex:bucket] doubleValue];
            for (NSNumber *sample in samples) {
                if (([sample doubleValue] >= low) && ([sample doubleValue] < high)) {
                    [result addObject:sample];
                    break;
                }
            }
        }
        return result;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to compare two arrays and get only the values that exist on
I am trying to compare two strings I get from a password form in
I'm trying to compare two datetimes but I can't get it to work. public
Currently I am trying to compare two variables, newhtml and oldhtml . I get
I am trying to compare a value which was grabbed using the get method
Compiling the following coe always get the same frustrating mistake. I'm trying to compare
How can I get a specific value from an object? I'm trying to get
I'm trying to get data from file. The file first has three lines of
Ok, I'm trying to get this working. This is my first time using LINQ.
I'm trying to use simpletest to compare two numeric strings, one from an array

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.