cllocation

Converting CLLocationCoordinates2D into an NSValue

こ雲淡風輕ζ 提交于 2019-12-20 03:14:56
问题 I'm simply trying to convert CLLocationCoordinates into an NSValue to be used in an array brought back later in my app. Here is my code: NSUInteger count = [self.locations count]; CLLocationCoordinate2D coordinates[count]; for (NSInteger i = 0; i < count; i++) { coordinates[i] = [(CLLocation *)self.locations[i] coordinate]; NSValue *locationValue = [NSValue valueWithMKCoordinate:coordinates[i]]; [_locationsArray addObject:locationValue]; NSLog(@"location = %@", _locationsArray); } However the

Need to archive CLLocation data

丶灬走出姿态 提交于 2019-12-19 07:56:13
问题 I have an array of CLLocation data that I would like to archive. Should the NSUserDefaults system be used? Otherwise, how best to archive the CLLocation data? 回答1: UserDefaults can only store certain types of data, and should be used to store user preference information, not arbitrary application state data. To quote the Apple docs: The NSUserDefaults class provides a programmatic interface for interacting with the defaults system. The defaults system allows an application to customize its

iOS Swift - CLGeocoder completionHandler block

你离开我真会死。 提交于 2019-12-19 04:57:07
问题 I'm trying to parse a location (CLLocation) into a String. func locationToString (currentLocation: CLLocation) -> String? { var whatToReturn: String? CLGeocoder().reverseGeocodeLocation(currentLocation, completionHandler: { (placemarks: [AnyObject]!, error: NSError!) in if error == nil && placemarks.count > 0 { let location = placemarks[0] as CLPlacemark whatToReturn = "\(location.locality) \(location.thoroughfare) \(location.subThoroughfare)" } }) return whatToReturn } Obviously,

didUpdateLocation Method Never Called

被刻印的时光 ゝ 提交于 2019-12-19 02:37:12
问题 I am making one app on iphone sdk4.0.In that did update location method never called. I have given my code below.Please help.Thanks in advance. -(id)init { [super init]; obj=[[UIApplication sharedApplication]delegate]; locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; //locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; // 100 m [locationManager startUpdatingLocation

How to get current location latitude and longitude in IOS SDK 8.0

丶灬走出姿态 提交于 2019-12-18 15:54:36
问题 how to get current location latitude and longitude. I have try this. Using Xcode 6.01 and IOS SDK 8.0 -(CLLocationCoordinate2D) getLocation{ locationManager = [[CLLocationManager alloc] init]; locationManager.delegate = self; locationManager.desiredAccuracy = kCLLocationAccuracyBest; locationManager.distanceFilter = kCLDistanceFilterNone; [locationManager startUpdatingLocation]; CLLocation *location = [locationManager location]; CLLocationCoordinate2D coordinate = [location coordinate];

Convert decimal coordinate into degrees, minutes, seconds, direction

随声附和 提交于 2019-12-18 11:31:41
问题 I have the following so far, but can't figure out a tidy way to get the direction letters in without a bunch of messy if statements. Any ideas? Ideally I'd like to extend the CLLocation class with a category to do this. -(NSString *)nicePosition{ double latitude = [self.latitude doubleValue]; double longitude = [self.longitude doubleValue]; int latSeconds = (int)round(latitude * 3600); int latDegrees = latSeconds / 3600; latSeconds = abs(latSeconds % 3600); int latMinutes = latSeconds / 60;

iPhone 3.0 Compass: how to get a heading?

牧云@^-^@ 提交于 2019-12-17 23:14:10
问题 I'm relatively new to Objective-C and really don't know much about it yet, so I apologise for what is probably a really amateurish question. I'm trying to get the magnetic heading from CLHeading and CLLocationDirection. However I'm getting compile errors for this line of code: locationLabel.text = [[[location course] magneticHeading] stringValue]; The errors are: warning: invalid receiver type 'CLLocationDirection' error: cannot convert to a pointer type I don't really understand what I'm

didUpdateLocations not called

柔情痞子 提交于 2019-12-17 15:36:10
问题 I'm trying to get my current location, but the break point in didUpdateLocations is never being called. LocationManager: locationManager = [[CLLocationManager alloc] init]; [locationManager setDelegate:self]; [locationManager setDesiredAccuracy:kCLLocationAccuracyBest]; [locationManager setDesiredAccuracy:kCLDistanceFilterNone]; [locationManager startUpdatingLocation]; Delegate method: - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations; I confirmed

Calculating bearing between two CLLocation points in Swift [duplicate]

情到浓时终转凉″ 提交于 2019-12-17 09:32:26
问题 This question already has answers here : CLLocation Category for Calculating Bearing w/ Haversine function (6 answers) Closed 5 years ago . I'm trying to calculate a bearing between two CLLocation points in swift-only code. I've run into some difficulty and was assuming this is a pretty simple function. Stack overflow didn't seem to have anything listed. func d2r(degrees : Double) -> Double { return degrees * M_PI / 180.0 } func RadiansToDegrees(radians : Double) -> Double { return radians *

Dictionary becomes nil when trying to pass back CLLocation object to iOS app extension

落花浮王杯 提交于 2019-12-13 13:37:48
问题 I'm trying to pass a stored CLLocation object from my iOS app back to an extension (in that case: an Apple Watch extension). For that, I'm using the recommended openParentApplication(userInfo: [NSObject : AnyObject]!, reply: (([NSObject : AnyObject]!, NSError!) -> Void)!) -> Bool function from the WKInterfaceController class in the extension code. I'm successfully receiving the request in my iOS app through the application delegate's application(application: UIApplication!,