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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:33:16+00:00 2026-05-31T04:33:16+00:00

Doesn’t seem to be anything about this online, I need to run fetch query

  • 0

Doesn’t seem to be anything about this online, I need to run fetch query ordered by distance from the users current location. My first plan was to create a transient property…

- (CLLocationDistance)distance {
    return [self.location distanceFromLocation:locationManager.location];   
}

But then I found out core data won’t fetch based on a transient property, which I thought might be the case as the fetch is turned into a SELECT statement with an ORDER BY clause so my distance property needs to exist in the database.

Ok so my second idea was to achieve this the same way I did in another project that used SQLite without Core Date using a custom sqlite function created with sqlite3_create_function…

static void sqliteDistance(sqlite3_context *context, int argc, sqlite3_value **argv) {
    if(sqlite3_value_type(argv[0])==SQLITE_NULL || sqlite3_value_type(argv[1])==SQLITE_NULL) {
        sqlite3_result_null(context);
    } else {
        sqlite3_result_double(context, [locationManager.location distanceFromLocation 
            [[CLLocation alloc] initWithLatitude: sqlite3_value_double(argv[0]) longitude: sqlite3_value_double(argv[1])]]);
}

}

Now question is how would I call this function from a core data fetch query? Im guessing its probably not possible as core data’s purpose is to abstract away the details of the backing store but maybe someone knows different?

  • 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-31T04:33:17+00:00Added an answer on May 31, 2026 at 4:33 am

    You are right, this isn’t possible using Core Data. Don’t forget that other backing store types are possible. How would it execute that query against XML?

    If you just need to sort the results why not set a sort descriptor on the array after you perform the fetch (assuming the dataset isn’t too large)?

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

Sidebar

Related Questions

Why doesn't this work (when parameter is set to 1) : SELECT * FROM
This doesn't work: $to = 'myemail@gmail.com'; $from = 'test@test.com'; $subj = 'test'; $message =
There doesn't seem to be a question for this, and it seems strange that
This doesn't work. I've got an exception from SQL databse that column does not
Why doesn't my MySQL query work? Query: DELETE FROM jos_community_awards a LEFT JOIN jos_community_users
This doesn't seem to work: NSString *string = [[NSString alloc] init]; string = @%@M,
Why doesn't the CAST work in this MySQL query? SELECT MAX(Signups) AS Max, MIN(Signups)
There doesn't seem to be any mention of this on facebook's API. I found
It doesn't seem to be working. The styles of nth-child(2) need to be differnt
Doesn't seem to work for me, maybe I just doing it wrong

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.