GithubHelp home page GithubHelp logo

flashlib / cllocationmanager-singleton-in-swift Goto Github PK

View Code? Open in Web Editor NEW

This project forked from igroomgrim/cllocationmanager-singleton-in-swift

0.0 2.0 0.0 58 KB

Simply to share location services

Home Page: http://www.igroomgrim.com/cllocationmanager-singleton-in-swift-2/

Swift 100.00%

cllocationmanager-singleton-in-swift's Introduction

CLLocationManager-Singleton-in-Swift

Simply to share location services. Example Singleton class use for share location service in swift. This class will auto update location when user change current location.

Updated for Swift 3

Swift 3 Version

Requirements

  • Xcode 7 or higher
  • Swift 2.0+
  • Apple LLVM compiler
  • iOS 8.0 or higher
  • ARC

Installation

  • Copy LocationService.swift to your project
  • add the key "NSLocationAlwaysUsageDescription" to a property list(Info.plist) and set its value to some message what you want. etc. "We requires access to your phone's location bla bla bla :P"
  • or add the key "NSLocationWhenInUseUsageDescription" if you want to access the user's location normally while running in the foreground.

How to use - Get currentLocation singleton

Call startUpdatingLocation() for start update your current location

LocationService.sharedInstance.startUpdatingLocation()

Call stopUpdatingLocation() if you want to stop update your current location

LocationService.sharedInstance.stopUpdatingLocation()

And if you want to get your current location just use

LocationService.sharedInstance.currentLocation

How to use - Get real time location by delegate

Conform LocationServiceDelegate protocol to your view controller and don't forget import CoreLocation

import CoreLocation
class ViewController: UIViewController, LocationServiceDelegate {
	override func viewDidLoad() {
        super.viewDidLoad()
        
        // Don't forget implement delegate 
        LocationService.sharedInstance.delegate = self
    }
}

We have 2 delegation method for tracing your location and let you know if has error

func tracingLocation(currentLocation: CLLocation){}
func tracingLocationDidFailWithError(error: NSError) {} 

Example Appication : Tracing

This example app uses location services in a potentially nonobvious way while running in the foreground or the background. You can see how to use in example application in this repository ... Good luck, Have fun :P

Contact Me

Anak Mirasing

cllocationmanager-singleton-in-swift's People

Contributors

igroomgrim avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.