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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:33:50+00:00 2026-06-05T20:33:50+00:00

I have an object from a NSObject class that I call brand and has

  • 0

I have an object from a NSObject class that I call “brand” and has the following properties:

.name
.number
.site

at a given time, dozens of these objects are stored on a NSMutableArray, something like:

object 1
object 2
object 3
object 4
...

I would like to be able to retrieve a given object from the array by its number. Not the index of the object on the array but the number property of the object (get object
that has the number property equal to 10, for example).

I know that NSArrays have smart methods for retrieving stuff but I don’t know them deeply cause I use this rarely. Is there any way to retrieve that object from the array without having to iterate thru all objects on the array and check each object’s number property?

Can you guys help? 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-06-05T20:33:52+00:00Added an answer on June 5, 2026 at 8:33 pm

    I would recommend NSPredicate. You could do it with something like this, assuming listOfItems is your array containing your NSObject‘s with said properties.

    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"number == 10"];
    NSArray *filtered = [listOfItems filteredArrayUsingPredicate:predicate];
    

    Your filtered results, any numbers matching 10 will now be in the filtered array. If you want to cast back to your object, you can do something like this:

    YourObject *object = (YourObject*)[filtered objectAtIndex:0];
    

    Hope this helps.

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

Sidebar

Related Questions

I have a class that has been derived from NSObject. How can copy be
I have a stdClass object created from json_decode that won't return the right number
I have the following code that loads a user's Active Directory DirectoryEntry object from
I have my own object class from inherited from NSObject @interface BlockedCell : NSObject
I have an object I'm trying to populate from another object (that is, iterate
I have a query that is pulling users who liked a specific object from
--Summary (shortened)-- I have a controller that loads a profile object from the corresponding
Suppose we have a class. We create an object from the class and when
lets say I have an NSWindow Class, that has several events for mouse and
I have a Cocoa project with an object that holds information from a SQLite

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.