2012-08-12 42 views
0

没有错误 - 编译时或在运行时抛出的异常...建立良好。我在做内存管理错了吗? ARC已针对所有文件启用。CLLocation Manager中断

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 { 

它只是说线程1断点.. 。我不知道如何阅读调试器(它只是提供了一些十六进制,我不知道该怎么办......)

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

回答

0

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