cllocation

Saving Swift CLLocation in CoreData

那年仲夏 提交于 2019-11-30 13:06:05
问题 I am trying to save CLLocation data in Core Data. My property is set as a Transformable object. Some sample code out there indicates one can save the location data using this objc converted to an NSValue . CLLocationCoordinate2D myLocation; NSValue *locationValue = [NSValue valueWithBytes:&myLocation objCType:@encode(CLLocationCoordinate2D)] // then put locationValue into storage - maybe an ObjC collection class or core data etc. Retrieving the object from the data store is supposed to work

Getting Altitude(height from sea level) of my location in iphone SDK

萝らか妹 提交于 2019-11-30 10:07:27
I am trying to get Altitude of my location in my application. But every time I try altitude property of CLLocation object I am getting 0.00 as result. I googled for my query and I got a similar question here and here . This link is saying that if I access CLLocation with wifi or cell tower it will be null. Even if I try to set desireAccuracy to best than even it don't make sure that app will use GPS. It is also saying that if I am indoor that I won't be able to access GPS. I many cases it its not sure that app will use GPS only. I want some way for getting Altitude from wifi or cell tower too.

recieving location updates after app is terminated

喜你入骨 提交于 2019-11-30 09:56:16
I need to keep track of the user location all the time (but not drain the battery). I understand the only way to get updates after app is terminated is using startMonitoringSignificantLocationChanges. From Apple's Location Awareness Programming Guide on startMonitoringSignificantLocationChanges: If you start this service and your application is subsequently terminated, the system automatically relaunches the application into the background if a new event arrives. In such a case, the options dictionary passed to the application:didFinishLaunchingWithOptions: method of your application delegate

How to store CLLocationCoordinate2D?

旧街凉风 提交于 2019-11-30 09:27:41
I'm attempting to build an application that builds and saves routes similar to map my run. I'm using the Breadcrumb sample code, specifically the CrumbPath and CrumbPathView as the base of my routes, from Apple. Two questions: If I try to access the MKMapPoint *points object of the CrumbPath like so: [_route lockForReading]; NSLog(@"%@", _route.points); NSLog(@"%d", _route.pointCount); [_route unlockForReading]; my app crashes, saying: Thread 1: EXC_BAD_ACCESS (code: 1, address: 0x9450342d) Which I have a hard time understanding, because within the CrumbPath.m file, the folks at apple write to

How to measure the distance in meters between two CLLocations?

白昼怎懂夜的黑 提交于 2019-11-30 08:01:16
问题 How can I get the distance in meters between two CLLocation s? CLLocation doesn't provide any method to do it, it seeems. 回答1: CLLocationDistance distance = [aCLLocationA distanceFromLocation:aCLLocationB]; // distance is a double representing the distance in meters 回答2: CLLocationDistance distance = [secondLocation distanceFromLocation:firstLocation]; // distance is expressed in meters CLLocationDistance kilometers = distance / 1000.0; // or you can also use this.. CLLocationDistance meters

put CLLocationCoordinate2D into CLLocation for Swift

我是研究僧i 提交于 2019-11-30 06:47:11
I have a method I want to call however when I get back the center of the map, it is in CLLocationCoordinate2D type. How do I put the results of CLLocationCoordinate2D into CLLocation? Figured it out. When mapView changes region, get the Lat and Lon from CLLocationCoordinate2D and create a CLLocation variable with the lat and lon passed in. func mapView(mapView: MKMapView!, regionDidChangeAnimated animated: Bool){ var centre = mapView.centerCoordinate as CLLocationCoordinate2D var getLat: CLLocationDegrees = centre.latitude var getLon: CLLocationDegrees = centre.longitude var getMovedMapCenter:

CLLocationManager on iPhone Simulator fails with kCLErrorDomain Code=0

与世无争的帅哥 提交于 2019-11-30 06:44:40
问题 CLLocationManager on iPhone Simulator is supposed to fake Cupertino (isn't it?) but it does NOT, it fails with kCLErrorDomain Code=0 instead. LocationManager's delegate receives the message didFailWithError . This method is implemented to log the error and the console outputs the following: Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)" I was working on a real project when I ran into this problem but it is pointless to discuss my code

Saving Swift CLLocation in CoreData

只愿长相守 提交于 2019-11-30 05:24:59
I am trying to save CLLocation data in Core Data. My property is set as a Transformable object. Some sample code out there indicates one can save the location data using this objc converted to an NSValue . CLLocationCoordinate2D myLocation; NSValue *locationValue = [NSValue valueWithBytes:&myLocation objCType:@encode(CLLocationCoordinate2D)] // then put locationValue into storage - maybe an ObjC collection class or core data etc. Retrieving the object from the data store is supposed to work using this paradigm. CLLocationCoordinate2D myLocation; NSValue *locationValue = // restored from your

Decoding the CLLocationAccuracy const's

爱⌒轻易说出口 提交于 2019-11-29 20:08:11
the following are listed in CLLocation.h but from my experience they are deceiving names- possibly originally thought up to serve two purposes, 1. to test the accuracy of the location returned, but also 2. to set how hard the location manager works, specifically what is enabled (gps (how many sat channels), how hard the wifi works, triangulation etc. extern const CLLocationAccuracy kCLLocationAccuracyBestForNavigation; // (raw value: -2) extern const CLLocationAccuracy kCLLocationAccuracyBest; // (raw value: -1) extern const CLLocationAccuracy kCLLocationAccuracyNearestTenMeters; // (raw value

Converting CLLocationCoordinate2D to a String that can be stored

寵の児 提交于 2019-11-29 11:23:40
I'm trying to save the coordinates of a user while in one ViewController so that it can be used to create an Annotation that can displayed in another ViewController. In the view controller that stores the coordinates I'm using the code NSUserDefaults.standardUserDefaults().setObject( Location, forKey: "Location") In the map view controller that displays the annotation I'm trying to get the coordinates using the code let Location = NSUserDefaults.standardUserDefaults().stringForKey("Location") var Annotation = MKPointAnnotation() Annotation.coordinate = Location It is telling me that the value