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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:32:29+00:00 2026-05-24T10:32:29+00:00

Basically, I have a database of locations for an MKMapView, and when the detail

  • 0

Basically, I have a database of locations for an MKMapView, and when the detail disclosure button on each annotation is tapped, it brings up more information on the location, for example their website and phone number.

Problem is, in my database some coordinates only have 4 or 5 decimal points instead of 6, so when the button was tapped the app would crash.
To stop this I added in the UIAlertView to say “We are unable to locate more information”
Is there any way to use my predicate in a better way?

NSString *lat = [NSString stringWithFormat:@"%.6f", view.annotation.coordinate.latitude];
NSString *lon = [NSString stringWithFormat:@"%.6f", view.annotation.coordinate.longitude];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Stores" inManagedObjectContext:_managedObjectContext];
[request setEntity:entity];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"Latitude == %@ && Longitude == %@", lat, lon];
[request setPredicate:predicate];

NSError *error = nil;
NSArray *stores = [_managedObjectContext executeFetchRequest:request error:&error];
[request release];
if (![stores count]) {
    UIAlertView *alert = [[[UIAlertView alloc]initWithTitle:@"Error" message:@"Sorry, we are unable to locate more information for this location." delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles: nil]autorelease];
    [alert show];
 } else {



    Stores *currentStore = [stores objectAtIndex:0];
    NSLog(@"current store %@", currentStore);

    AddressAnnotation *annotation = view.annotation;

    MoreInfoTable *moreInfoView = [[MoreInfoTable alloc] initWithStyle:UITableViewStyleGrouped];
    moreInfoView.currentStore = currentStore;
    moreInfoView.managedObjectContext = self.managedObjectContext;
    moreInfoView.title = annotation.title ;
    moreInfoView.getWebsite =[NSURL URLWithString:annotation.website];
    moreInfoView.getDirections = [NSURL URLWithString:[NSString stringWithFormat:@"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f", mapView.userLocation.coordinate.latitude, mapView.userLocation.coordinate.longitude, annotation.coordinate.latitude, annotation.coordinate.longitude]];
    moreInfoView.footer = [NSString stringWithFormat:@"%.1f miles away", annotation.distanceFromLocation];
    moreInfoView.address = annotation.address;
    moreInfoView.getPhoneNumber = [NSMutableString stringWithString:annotation.phoneNumber];
    moreInfoView.lat = view.annotation.coordinate.latitude;
    moreInfoView.lon = view.annotation.coordinate.longitude;

    [self.navigationController pushViewController:moreInfoView animated:YES];
    [moreInfoView release]; 

}

}
  • 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-24T10:32:31+00:00Added an answer on May 24, 2026 at 10:32 am

    I’m assuming you are trying to get all Stores entities which have a lat or lon. You should check Latitude or Longitude != nil instead of comparing to your 6 decimal string.

    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"Latitude != nil && Longitude != nil"];
    [request setPredicate:predicate];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I have a database with two tables, that is, Updates table and Images
basically i have a database, which contains a random amount of questions i have
So! Basically I have a database with a load of blog posts, these are
We have a registration system Database and basically what this query does is check
I have to design a database to handle forms. Basically, a form needs to
Basically, I have an RPG-type Rails application. I'm storing skills in a skills database
Let's say I have a Type II SCD database, that is basically append only.
Basically, I have a Sql Server database whose schema changes. When this happens, I
I have a location class. This class basically holds addresses, hence the term location.
Basically, I am doing this: I have already read the database and obtained all

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.