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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:43:08+00:00 2026-05-24T10:43:08+00:00

Currently, If I want to search whether an object is in a NSArray(not sorted)

  • 0

Currently, If I want to search whether an object is in a NSArray(not sorted) or not. I have to loop over the array and check each object until I found one that match my expectation.

I doubt it’s performance even if the check is only a if statement.

To improve the search performance is there any provided solution?

Or I can only sort the array some way and use some way like binary-search?

  • 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-24T10:43:09+00:00Added an answer on May 24, 2026 at 10:43 am

    Sorting then searching will take more time than a loop iterating over each element of the array since comparison based sorting takes at best O(n * log(n)) time, iterating over the array will take O(n) time for n elements in the array.

    A pragmatical solution would be to use NSArray#containsObject if you already know the object.

    Otherwise you have to implement your own comparison strategy and step through the array

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

Sidebar

Related Questions

I want to implement semantic search into my rails site. I currently have a
I want the tr that's currently hovered over to change color, and then change
I currently have a listview and I want to add an appropriate icon to
I currently have links w/ class=ajax that I want to retrieve the element with
I have an array of 1000-2000 elements which are pointers to objects. I want
I want to search whether a given GeoPoint is within a given radius provided
I have an array, inside an array. I'd like to search the values in
Well i currently want to do a search engine with SQL and PHP. I
I want fulltext search for my JavaScript code, but I'm usually not interested in
I have several asp.net website projects for various sites. Currently I want to add

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.