-3
#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;

提前致谢!

4

2 回答 2

2

您不能在@interface零件中编写函数体。将它们移动到.m文件中,在@implementation.

于 2013-07-08T13:13:23.850 回答
1

除了汤姆的回答你需要;在 your.m 文件中删除你的 ibaction 方法

改变

- (IBAction)toggleLocationUpdates:(id)sender;

- (IBAction)toggleLocationUpdates:(id)sender {}

于 2013-07-08T13:17:52.560 回答