dan1eln1el5en
dan1eln1el5en

Reputation: 53

IOS Obj-C extracting latitude from CLLocation

I'm updating an Obj-C project, and a model for a "upload model" is made with a CLLocation of similar to this: NSLog output:

<+38.03744507,+122.80317688> +/- 0.00m (speed -1.00 mps / course -1.00) @ 8/23/16, 9:44:41 PM Central European Summer Time

So I would assume I could just extract that data as this:

CLLocation *lat = self.currentUploadPackage.placeLocation.coordinate.latitude;

I get to placeLocation, but Xcode claims that it doesn't contain coordinate nor latitude

(/Users/user/Development/app/ShareDescriptionViewController.m:92:37: Property 'latitude' cannot be found in forward class object 'CLLocation')

How do I go about getting the long/lat data from the CLLocation mentioned above? Or any hints.

(PS: I am not good with ObjC, as I focused on Swift)

Upvotes: 1

Views: 130

Answers (1)

rmaddy
rmaddy

Reputation: 318804

Note that the error mentions "forward class object 'CLLocation'".

This means you use @class CLLocation somewhere (probably in some .h file). But this doesn't provide any details about CLLocation other than it is some class.

To fix your code you need to import the proper .h file in the .m file that actually tries to access properties of CLLocation.

#import <CoreLocation/CLLocation.h>

Upvotes: 2

Related Questions