#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;
提前致谢!
答案 0 :(得分:2)
您无法在@interface
部分编写函数体。将它们移至.m
中的@implementation
文件。
答案 1 :(得分:1)
除了Tom的回答你需要在your.m文件中删除你的ibaction方法的;
变化
- (IBAction)toggleLocationUpdates:(id)sender;
到
- (IBAction)toggleLocationUpdates:(id)sender {}