Skip to content

GPSwift allows you to simple connect to CoreLocation framework and returns address in human readable format.

License

Notifications You must be signed in to change notification settings

peterdruska/GPSwift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GPSwift

GPSwift allows you to simple connect to CoreLocation framework and returns address in human readable format.

GPSwift.swift

File creates singleton class to provide geo location update data in human readable structure.

Install

Copy GPSwift.swift file to your project.

In viewController just create variables of CLLocationManager and GPSwift:

var locationManager = CLLocationManager()
var gpsLocation: GPSwift!

Create singleton instance:

gpsLocation = GPSwift.sharedGPS

Then just simple start locating:

gpsLocation.startLocating()

or stop locating:

gpsLocation.stopLocating()

After succesfull location update GPSwift singleton post observer named locationChangedNotification. So add observer to viewController like this:

NSNotificationCenter.defaultCenter().addObserver(
    self,
    selector: "locationHasChanged",
    name: locationChangedNotification,
    object: nil)

Then use function locationHasChanged to read geo located address:

func locationHasChanged() {
    println("\(gpsLocation.address.thoroughfare)")
    println("\(gpsLocation.address.subThoroughfare)")
    println("\(gpsLocation.address.locality)")
    println("\(gpsLocation.address.postalCode)")
    println("\(gpsLocation.address.ISOcountryCode)")
}

And that's it.

Happy geo locating.

Screens

Preview

Preview

About

GPSwift allows you to simple connect to CoreLocation framework and returns address in human readable format.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages