CLLocationManager中断

时间:2012-08-12 05:48:17

标签: iphone objective-c core-location

没有错误 - 在运行时抛出的编译时间或异常...构建正常。我做内存管理错了吗? ARC已启用所有文件。

viewcontroller.h:

#import <UIKit/UIKit.h>

@interface workViewController : UIViewController 
<CLLocationManagerDelegate>{

    CLLocationManager *locationManager; 

}


@property (strong, nonatomic) IBOutlet CLLocationManager *locationManager;

@end

viewcontroller.m:

#import "workViewController.h"

@interface workViewController ()

@end

@implementation workViewController
@synthesize locationManager;


-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {

    NSLog(@"i worked lol");


}
- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the 
    //view, typically from a nib.

    locationManager.delegate = self;

    [locationManager startUpdatingLocation];

}

- (void)viewDidUnload
{
    [locationManager stopUpdatingLocation];
    [self setLocationManager:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

@end

prefix.pch:

#import <Availability.h>

#ifndef __IPHONE_5_0
#warning "This project uses features only available in iOS SDK 5.0 and later."
#endif

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
    #import <CoreLocation/CoreLocation.h>
#endif

无论如何,这个代码在我第一次构建应用程序时起作用了。我一直在苦苦挣扎,主要是它有时工作,其他时候根本不工作,直到我重新启动计算机。我做内存管理完全错了吗?

这让我感到困惑,因为我确保我逐行遵循教程......

应用程序在调用委托方法的地方中断:

    -(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {

它只是说thread1断点...而且我不确定如何读取调试器(它只是提供了一些我不知道如何处理的十六进制......)

无论如何,我很想知道我做错了什么!

1 个答案:

答案 0 :(得分:0)

尝试初始化CLLocationManager对象。一般来说,你选择这样做的方式很奇怪。通常使用Core Location,您将创建一个实现didUpdateToLocation和didFailWithError的对象,创建一个委托协议,并在您需要该位置的主线程中初始化该对象,然后调用startUpdatingLocation。