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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:26:08+00:00 2026-05-29T11:26:08+00:00

I have a list of items in an entity in Core Data on the

  • 0

I have a list of items in an entity in Core Data on the iphone all of them have an item_id integer attribute. I need to return the highest numbered item_id and the lowest numbered item_id that are in the table with one fetch request. I do not have any knowledge of what those numbers might be as they do not start at 0 and go up.

What would be the best way to accomplish this? Again, I know I can do it with 2 separate fetch requests, is there a way to do it with just one?

  • 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-29T11:26:08+00:00Added an answer on May 29, 2026 at 11:26 am

    That’s a tricky one to do in only ONE fetch. I would do two fetches using the MAX and MIN functions / expressions. e.g.

    NSExpression *minExpression = [NSExpression expressionForFunction:@”min:”
    arguments:[NSArray arrayWithObject:keyPathExpression]];
    

    If you absolutely have to do it in ONE fetch then I can only think to do a fetchAll and sort by the id, then get the first and last via:

    [objects objectAtIndex:0]
    [objects lastObject] 
    

    Update 1:
    Looks like this guy has a solution:
    http://useyourloaf.com/blog/2012/1/19/core-data-queries-using-expressions.html

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

Sidebar

Related Questions

I have a Core Data List entity that has an ordered relationship to ListItems.
I have a list of geographical locations in Core Data (entity name is Stops).
How can I query the DB to return a list of items that have
In my app I'm following CoreDataBooks for implementing Core data. I have a list
I have a core data entity that represents the attributes of a product, as
I've got a collection of items (ADO.NET Entity Framework), and need to return a
I have a Core Data entity called Item and it represents an item in
I have two core data entities. Lets call them AAA and BBB . BBB
Within my code I have list items like this; <div id=content> <ul class=kwicks> <li
I have 5 list items, when one is clicked the only method I know

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.