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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:56:46+00:00 2026-05-15T01:56:46+00:00

I am using a predicate to find an object in core data. I can

  • 0

I am using a predicate to find an object in core data. I can successfully find the object that I want, but I need to also get the indexPath of that object, so that I can push a details view in for that object. Currently I have the following code for getting my object:

    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    [fetchRequest setEntity:[NSEntityDescription entityForName:@"Ride" inManagedObjectContext:self.managedObjectContext]];
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"title = %@ AND addressFull = %@", view.annotation.title, view.annotation.subtitle];
    [fetchRequest setPredicate:predicate];
    NSMutableArray *sortDescriptors = [NSMutableArray array];
    [sortDescriptors addObject:[[[NSSortDescriptor alloc] initWithKey:@"title" ascending:YES] autorelease]];
    [sortDescriptors addObject:[[[NSSortDescriptor alloc] initWithKey:@"addressFull" ascending:YES] autorelease]];
    [fetchRequest setSortDescriptors:sortDescriptors];
    [fetchRequest setReturnsObjectsAsFaults:NO];
    [fetchRequest setPropertiesToFetch:[NSArray arrayWithObjects:@"title", @"addressFull", nil]];
    NSError *error = nil;
    NSArray *fetchedItems = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];
    // Sohow what record we returned
    NSLog(@"%@",[fetchedItems objectAtIndex:0]);

So, I can correctly get my object into an array. But how do I translate that object into an indexPath?

  • 1 1 Answer
  • 1 View
  • 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-15T01:56:47+00:00Added an answer on May 15, 2026 at 1:56 am

    An index path is just a set of indices, e.g. {0, 2} might represent an index path pointing at the first section and third row of a table view — assuming a table view representation of your array data is your ultimate goal.

    That index path could point to any particular object in your array, depending on how you translate the path to an index of your array.

    If you want to make an arbitrary index path, it’s pretty easy:

    NSUInteger myFirstIndex = 0;
    NSUInteger mySecondIndex = 2;
    NSUInteger myIndices[] = {myFirstIndex, mySecondIndex};
    NSIndexPath *myIndexPath = [[NSIndexPath alloc] initWithIndexes:myIndices length:2];
    // ...do someting with myIndexPath...
    [myIndexPath release];
    

    So what you need to do is figure out how your array structure translates to sections and rows (again, assuming you want to make a table view representation).

    Another option is to use an NSFetchedResultsController to handle table view updates for you — it will handle index paths for you, depending on how you partition your sections.

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

Sidebar

Related Questions

I want to mock Find method which expects a predicate using Moq: public PurchaseOrder
I am using the visual editor for creating a Core Data model. I can't
Having a bit of trouble using the List.Find with a custom predicate i have
I have been using the scikits.statsmodels OLS predict function to forecast fitted data but
Using Location.getBearing(); I seem to get randomly changing bearings. Aka, I can turn the
I'm working on an iPhone and I'm using Core Data as my store. What
I want to find a specific object in a std::list where the object's attribute
How would I convert the following to a VB.NET predicate using Array.Find? Private Function
I want to create an object with a constructor containing predicate and func objects
How to use properly the code below? public IEnumerable<T> Find(Expression<Func<T, bool>> predicate) I need

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.