#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
@interface ViewController : UIViewController<CLLocationManagerDelegate>
{
CLLocationManager *_locationManager;
}
@property (strong, nonatomic) IBOutlet UISwitch *locationUpdatesSwitch;
@property (strong, nonatomic) IBOutlet UILabel *locationInformationLabel;
- (IBAction)toggleLocationUpdates:(id)sender;
{ //EXPECTED IDENTIFIER OR "("
if (self.locationUpdatesSwitch.on == YES)
{
if ([CLLocationManager locationServicesEnabled] == NO)
{
UIAlertView *locationServicesDisabledAlert =
[[UIAlertView alloc] initWithTitle:@"Location Services Disabled"
message:@"This feature requires location services. Enable it in the privacy settingson your device"
delegate:nil
cancelButtonTitle:@"Dismiss"
otherButtonTitles:nil];
[locationServicesDisabledAlert show];
self.locationUpdatesSwitch.on = NO;
return;
}
}
else
{
// Switch was turned Off
}
}
尝试在一个基于小型核心位置的 xcode 项目上工作。有人可以帮我吗?我没有看到我错过了什么,但我在 - (IBAction)toggleLocationUpdates:(id)sender;
提前致谢!