-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

;トムの答えに加えて、.mファイルのibactionメソッドを削除する必要があります

変化する

- (IBAction)toggleLocationUpdates:(id)sender;

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

于 2013-07-08T13:17:52.560 に答える