由於它在寫入文檔中,我的應用程序在啓動後立即崩潰。我真的不知道該怎麼做。謝謝你的幫助。這裏是代碼:我的應用程序在啓動後立即崩潰
#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
崩潰後,它顯示了這個: http://i.stack.imgur.com/k0eVO.png
你能告訴我們什麼是在調試器打印? – Priyatham51 2015-04-05 10:19:42
你看過http://stackoverflow.com/questions/24850128/ios-8-requestwheninuseauthorization-no-popup嗎? – luk2302 2015-04-05 11:26:43
掛鉤lldb並檢查後面的跟蹤 – Wingzero 2015-04-05 13:20:41