Skip to content

Commit

Permalink
Fights static access to make singleton. Refs #37.
Browse files Browse the repository at this point in the history
  • Loading branch information
gradha committed May 30, 2015
1 parent cbc2500 commit b892e92
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
3 changes: 3 additions & 0 deletions src/App_delegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#import "controllers/Tab_controller.h"
#import "db/DB.h"
#import "macro.h"
#import "Record_my_position-Swift.h"

#import "EHReachability.h"

Expand Down Expand Up @@ -64,6 +65,8 @@ - (BOOL)application:(UIApplication *)application
{
DLOG(@"Lunching application with %@", launch_options);

[[SGPS get] start];

[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES];
_set_globals();
[DB preserve_old_db];
Expand Down
40 changes: 28 additions & 12 deletions src/SGPS.swift
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
import Foundation

class SGPS
public class Test
{
static let cInstance: SGPS = SGPS()
init(a: String) {
println("Hello \(a)")
}
}

@objc public class SGPS
{
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

get { return cInstance; }
init()
static func get() -> SGPS {
return cInstance
}

public init()
{
let defaults = NSUserDefaults.standardUserDefaults
let gpsIsOn = defaults.boolForKey(_GPS_IS_ON_KEY);
let defaults = NSUserDefaults.standardUserDefaults()

if defaults.boolForKey(_GPS_IS_ON_KEY) {
start();
}
SGPS.cSaveAllPositions = defaults.boolForKey(_KEY_SAVE_SINGLE_POSITION);
}

public func start()
{
println("Starting!");
}
}
// const BOOL gps_is_on = [defaults boolForKey:_GPS_IS_ON_KEY];
// if (gps_is_on)
// [g_ start];
//
// g_->save_all_positions_ =
// ![defaults boolForKey:_KEY_SAVE_SINGLE_POSITION];

0 comments on commit b892e92

Please sign in to comment.