-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds some getters and setters. Refs #37.
- Loading branch information
Showing
1 changed file
with
54 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,78 @@ | ||
import Foundation | ||
import CoreLocation | ||
|
||
public class Test | ||
|
||
enum Accuracy | ||
{ | ||
init(a: String) { | ||
println("Hello \(a)") | ||
} | ||
case High, Medium, Low | ||
} | ||
|
||
@objc public class SGPS | ||
@objc public class SGPS : NSObject, CLLocationManagerDelegate | ||
{ | ||
private let _GPS_IS_ON_KEY = "gps_is_on" | ||
private let _KEY_SAVE_SINGLE_POSITION = "save_single_positions" | ||
|
||
static private let cInstance: SGPS = SGPS(); | ||
static private var cSaveAllPositions: Bool = false | ||
private var mSaveAllPositions: Bool { | ||
get { return self.mSaveAllPositions } | ||
set { | ||
let defaults = NSUserDefaults.standardUserDefaults() | ||
defaults.setBool(newValue, forKey:_KEY_SAVE_SINGLE_POSITION) | ||
defaults.synchronize() | ||
} | ||
} | ||
|
||
private var mManager: CLLocationManager | ||
private var mAccuracy: Accuracy | ||
|
||
static func get() -> SGPS { | ||
static func get() -> SGPS | ||
{ | ||
return cInstance | ||
} | ||
|
||
public init() | ||
override public init() | ||
{ | ||
let defaults = NSUserDefaults.standardUserDefaults() | ||
println("Initializing SGPS") | ||
mManager = CLLocationManager() | ||
//assert(nil !== mManager) TODO: Why does the check fail? | ||
mAccuracy = .High | ||
super.init() | ||
|
||
// Set no filter and try to get the best accuracy possible. | ||
mManager.distanceFilter = kCLDistanceFilterNone | ||
mManager.desiredAccuracy = kCLLocationAccuracyBest | ||
mManager.delegate = self | ||
|
||
let defaults = NSUserDefaults.standardUserDefaults() | ||
if defaults.boolForKey(_GPS_IS_ON_KEY) { | ||
start(); | ||
start() | ||
} | ||
mSaveAllPositions = defaults.boolForKey(_KEY_SAVE_SINGLE_POSITION) | ||
} | ||
|
||
deinit { | ||
stop() | ||
//mManager = nil | ||
} | ||
|
||
public var mGpsIsOn: Bool { | ||
get { | ||
return self.mGpsIsOn | ||
} | ||
set { | ||
let defaults = NSUserDefaults.standardUserDefaults() | ||
defaults.setBool(newValue, forKey:_GPS_IS_ON_KEY) | ||
defaults.synchronize() | ||
} | ||
SGPS.cSaveAllPositions = defaults.boolForKey(_KEY_SAVE_SINGLE_POSITION); | ||
} | ||
|
||
public func start() | ||
{ | ||
println("Starting!"); | ||
println("Starting!") | ||
} | ||
|
||
public func stop() | ||
{ | ||
println("Stopping") | ||
} | ||
} |