#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)發送;預計標識符或「(」
在此先感謝
哦!謝謝!剛開始使用xcode。 – user2560817
從技術上講,你應該可以在頭文件中編寫函數。但我認爲在這種情況下分號是問題。 – Jason