【发布时间】:2015-06-09 23:06:26
【问题描述】:
正如标题所写,我的应用程序在启动后立即崩溃。我真的不知道,该怎么办。谢谢你的帮助。这是代码:
#import "ViewController.h"
@import CoreLocation;
@interface ViewController () <CLLocationManagerDelegate>
@property (strong, nonatomic) CLLocationManager *locationManager;
@property (weak, nonatomic) IBOutlet UILabel *location;
@property (weak, nonatomic) IBOutlet UILabel *date;
@end
@implementation ViewController
-(void)viewDidLoad
{
[super viewDidLoad];
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;
if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
[self.locationManager requestWhenInUseAuthorization];
}
[self.locationManager startUpdatingLocation];
//date
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MMMM d, YYYY"];
NSString *dateString = [dateFormatter stringFromDate:[NSDate date]];
NSLog(@"%@", dateString);
self.date.text = (@"%@", dateString);
}
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
NSLog(@"%@", [locations lastObject]);
self.location.text = (@"%@", [locations lastObject]);
}
@end
【问题讨论】:
-
你能告诉我们调试器中打印的内容吗?
-
连接 lldb 并检查回溯
-
应用异常断点......并检查您是否将任何值存储到 userdefault 那么在启动应用程序和发展 userdefault 时它不应该为空
-
你确定这个类是什么导致你的应用崩溃?!
标签: ios objective-c iphone xcode