dan1eln1el5en dan1eln1el5en - 1 year ago 80
iOS Question

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

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
, but Xcode claims that it doesn't contain

(/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
mentioned above? Or any hints.

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

Answer Source

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>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download