Skip to content

Instantly share code, notes, and snippets.

@andrewschreiber
Created September 26, 2013 22:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewschreiber/6721499 to your computer and use it in GitHub Desktop.
Save andrewschreiber/6721499 to your computer and use it in GitHub Desktop.
WORKING. Issues overcome: Needed to initialize viewcontroller missing a XIB XIB not working with outlet XIB not initializing view (or whatever) Cant stop this
//
// WhereAmIAppDelegate.h
// Whereami
//
// Created by Andrew Schreiber on 9/25/13.
// Copyright (c) 2013 Andrew Schreiber. All rights reserved.
//
#import <UIKit/UIKit.h>
@class WhereAmIViewController;
@interface WhereAmIAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) WhereAmIViewController *viewController;
@end
//
// WhereAmIAppDelegate.m
// Whereami
//
// Created by Andrew Schreiber on 9/25/13.
// Copyright (c) 2013 Andrew Schreiber. All rights reserved.
//
#import "WhereAmIAppDelegate.h"
#import "WhereAmIViewController.h"
@implementation WhereAmIAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[WhereAmIViewController alloc] initWithNibName:@"WhereAmIViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end
//
// WhereAmIViewController.h
// Whereami
//
// Created by Andrew Schreiber on 9/25/13.
// Copyright (c) 2013 Andrew Schreiber. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
@interface WhereAmIViewController : UIViewController <CLLocationManagerDelegate>
{
CLLocationManager *locationManager;
IBOutlet UILabel *labeler;
}
//@property (nonatomic)CLLocationManager *locationManager;
@end
//
// WhereAmIViewController.m
// Whereami
//
// Created by Andrew Schreiber on 9/25/13.
// Copyright (c) 2013 Andrew Schreiber. All rights reserved.
//
#import "WhereAmIViewController.h"
@interface WhereAmIViewController ()
@end
@implementation WhereAmIViewController
- (id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
NSLog(@"Test1");
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if(self)
{
locationManager = [[CLLocationManager alloc]init];
[locationManager setDelegate:self];
//We want it to be as accurate as possible
//regardless of how much time/power it takes
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
//Tell our manager to start looking for its location immediately
[locationManager startUpdatingLocation];
NSLog(@"Test2");
}
return self;
}
- (void) locationManager:(CLLocationManager *) manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
NSLog(@"%@", newLocation);
}
- (void)locationManager:(CLLocationManager *)manager
didFailWithError:(NSError *)error
{
NSLog(@"Could not find location: %@ error",error);
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment