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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:38:59+00:00 2026-06-15T08:38:59+00:00

More for my interest than anything else. If you have an Class defined like

  • 0

More for my interest than anything else.

If you have an Class defined like so…

MyClass
-------
NSString *name

And you put a lot of them into an array (or mutable array). Then you can use a predicate like this…

[NSPredicate predicateWithFormat:@"name = %@", someValue];

to filter the array so that it only contains objects whose names are the value given.

Or sort descriptor like so…

[NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES];

to sort the array by the name field in ascending order.

My question is, if you have an array of strings (or of NSNumbers) can you use similar “format” predicates?

Say for instance you had the array…

@[@"Cat", @"Bat", @"Dog", @"Cow"];

Could you use a “predicateWithFormat” to filter this array of a “sortDescriptorWithKey” to sort it?

I know you can use blocks but just wondering if this is possible?

  • 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-15T08:39:00+00:00Added an answer on June 15, 2026 at 8:39 am

    Sure, you can filter an array of strings, or anything else, with predicateWithFormat:. As for sorting, you would use sortedArrayUsingSelector:, and use whichever selector you want (compare:, caseInsensitiveCompare:, etc.). There are no keys in a simple array, so you couldn’t use sortDescriptorWithKey.

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

Sidebar

Related Questions

More out of interest than anything else, but can you compile a DirectX app
More for interest than actual need... is it possible to have an automatically decreasing
More than one time I have encountered the following problem when building code with
More often than I'd have hoped I seem to come across method/property definitions in
This is more out of personal curiosity/interest than a specific problem I'm trying to
Is is possible to have a partial view inherit more than one model? I
I have an object model like this: public class Quantity { public decimal Weight
This more of an out of interest question than an urgently need an answer
i have a table report like this YYYYMM pipno demand principle interest balance=(demand-principle) 201010
My problem ought to be fairly simple and is more a question of interest

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.