没有错误——编译时或运行时抛出的异常......构建良好。我做错了内存管理吗?为所有文件启用 ARC。
视图控制器.h:
#import <UIKit/UIKit.h>
@interface workViewController : UIViewController
<CLLocationManagerDelegate>{
CLLocationManager *locationManager;
}
@property (strong, nonatomic) IBOutlet CLLocationManager *locationManager;
@end
视图控制器.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
前缀.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 断点...我不确定如何读取调试器(它只是提供了一些我不知道该怎么处理的十六进制...)
无论如何,我很想知道我做错了什么!