Skip to content

Commit

Permalink
Fixes computed properties. Refs #37.
Browse files Browse the repository at this point in the history
  • Loading branch information
gradha committed May 31, 2015
1 parent 81d6797 commit 08359b0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
5 changes: 4 additions & 1 deletion src/App_delegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ - (BOOL)application:(UIApplication *)application
{
DLOG(@"Lunching application with %@", launch_options);

[[SGPS get] start];
SGPS* test = [SGPS get];
[test start];
test.gpsIsOn = YES;
test.saveAllPositions = YES;

[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
_set_globals();
Expand Down
35 changes: 19 additions & 16 deletions src/SGPS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,15 @@ enum Accuracy
case High, Medium, Low
}

@objc public class SGPS : NSObject, CLLocationManagerDelegate
@objc 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();
private var mSaveAllPositions: Bool {
get { return self.mSaveAllPositions }
set {
let defaults = NSUserDefaults.standardUserDefaults()
defaults.setBool(newValue, forKey:_KEY_SAVE_SINGLE_POSITION)
defaults.synchronize()
}
}
static private let cInstance: SGPS = SGPS()

private var mSaveAllPositions = false
private var mGpsIsOn = false
private var mManager: CLLocationManager
private var mAccuracy: Accuracy

Expand All @@ -30,7 +24,7 @@ enum Accuracy
return cInstance
}

override public init()
override init()
{
println("Initializing SGPS")
mManager = CLLocationManager()
Expand All @@ -55,23 +49,32 @@ enum Accuracy
//mManager = nil
}

public var mGpsIsOn: Bool {
get {
return self.mGpsIsOn
var saveAllPositions: Bool {
get { return mSaveAllPositions }
set {
mSaveAllPositions = newValue
let defaults = NSUserDefaults.standardUserDefaults()
defaults.setBool(newValue, forKey:_KEY_SAVE_SINGLE_POSITION)
defaults.synchronize()
}
}

var gpsIsOn: Bool {
get { return mGpsIsOn }
set {
mGpsIsOn = newValue
let defaults = NSUserDefaults.standardUserDefaults()
defaults.setBool(newValue, forKey:_GPS_IS_ON_KEY)
defaults.synchronize()
}
}

public func start()
func start()
{
println("Starting!")
}

public func stop()
func stop()
{
println("Stopping")
}
Expand Down

0 comments on commit 08359b0

Please sign in to comment.