Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

GPS function to Build a Self-Destructing Message iPhone App

Hi!

I wonder if there is a way to add a GPS location to the users in the Build a Self-Destructing Message iPhone App?

3 Answers

of course! you could use a location manager (and the CLLocationManagerDelegate protocol) to get their location. See this location and maps programming guide for a more detailed walkthrough. This is a highly customizeable way to do it.

Parse also has methods that get the location of the user (although the degree and accuracy is not customizable like it is if you use a location manager). See here for parse documentation on geopoints. i would do it this way. its a few lines of code as opposed to many delegate methods etc.

then once the location is obtained you could add @"location" as a key of the message object and set it to the geopoint you obtained. You would have to prevent the user from sending the message until a location was obtained though by disabling the send button until then etc.

If you wanted to get information about the location (address, city, state, etc) you would have to reverse geocode the location which is covered in that apple guide I linked up top.

Thanks guys! Best forum ever!! I'm going to have a look :)