Skip to content

Commit

Permalink
Solves circular dependency, fixes other renamed calls. Refs #37.
Browse files Browse the repository at this point in the history
  • Loading branch information
gradha committed Jun 6, 2015
1 parent a0c5739 commit 02f29d6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/App_delegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ - (BOOL)application:(UIApplication *)application
[db_ log:[NSString stringWithFormat:@"Launch options? %@",
launch_options]];

[[EHGPS get] postInit];

tab_controller_ = [Tab_controller new];
[window_ addSubview:tab_controller_.view];

Expand Down
12 changes: 11 additions & 1 deletion src/EHGPS.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ import UIKit
return cInstance
}

/** Constructor for the class.
* The constructor avoids side effects moving some code to postInit()
* which you need to call.
*/
override init()
{
println("Initializing EHGPS")
DLOG("Initializing EHGPS")
mManager = CLLocationManager()
//assert(nil !== mManager) TODO: Why does the check fail?
mAccuracy = .High
Expand All @@ -43,7 +47,13 @@ import UIKit
mManager.distanceFilter = kCLDistanceFilterNone
mManager.desiredAccuracy = kCLLocationAccuracyBest
mManager.delegate = self
}

/** Finishes the initialization.
* Call this when the DB dependency is solved.
*/
func postInit()
{
let defaults = NSUserDefaults.standardUserDefaults()
if defaults.boolForKey(_GPS_IS_ON_KEY) {
start()
Expand Down
12 changes: 6 additions & 6 deletions src/controllers/Capture_tab.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ - (void)dealloc

[timer_ invalidate];
if (watching_)
[[EHGPS get] remove_watcher:self];
[[EHGPS get] removeWatcher:self];
[start_switch_ removeTarget:self action:@selector(gps_switch_changed)
forControlEvents:UIControlEventValueChanged];
[record_type_switch_ removeTarget:self
Expand Down Expand Up @@ -202,12 +202,12 @@ - (void)gps_switch_changed
start_switch_.on = false;
[self warn:@"Couldn't start GPS" title:@"GPS"];
} else {
[gps add_watcher:self];
[gps addWatcher:self];
watching_ = YES;
}
} else {
if (watching_)
[gps remove_watcher:self];
[gps removeWatcher:self];
watching_ = NO;
[gps stop];
}
Expand Down Expand Up @@ -271,10 +271,10 @@ - (void)update_gui
}

longitude_.text = [NSString stringWithFormat:@"Longitude: %@",
[EHGPS degrees_to_dms:location.coordinate.longitude latitude:NO]];
[EHGPS degreesToDms:location.coordinate.longitude latitude:NO]];

latitude_.text = [NSString stringWithFormat:@"Latitude: %@",
[EHGPS degrees_to_dms:location.coordinate.latitude latitude:YES]];
[EHGPS degreesToDms:location.coordinate.latitude latitude:YES]];

const CLLocationAccuracy v = (location.horizontalAccuracy +
location.horizontalAccuracy) / 2.0;
Expand Down Expand Up @@ -369,7 +369,7 @@ - (void)add_note
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary *)change context:(void *)context
{
if ([keyPath isEqual:[EHGPS key_path]])
if ([keyPath isEqual:[EHGPS KEY_PATH]])
[self update_gui];
else
[super observeValueForKeyPath:keyPath ofObject:object change:change
Expand Down

0 comments on commit 02f29d6

Please sign in to comment.