gpt4 book ai didi

iphone - objective-c : strange error when init a variable declared in my header file

转载 作者:行者123 更新时间:2023-12-02 10:49:40 25 4
gpt4 key购买 nike

当我添加以下行时,我得到:

locMan = [[CLLocationManager alloc] init];

对于我的.m文件中的 viewDidLoad方法,我遇到了一些以前从未见过的错误。错误如下:

我一生都无法弄清楚为什么添加该行会引起问题。如果有人能阐明一点,我将不胜感激。

我有这个头文件:
#import <UIKit/UIKit.h>
#import "CoreLocation/CoreLocation.h"


@interface RobotWarsViewController : UIViewController
<CLLocationManagerDelegate> {

CLLocationManager *locMan;

// Current Location View
IBOutlet UIView *currentLocationView;
IBOutlet UILabel *currentLocationLabel;


}

@property (assign, nonatomic) UIView *currentLocationView;
@property (assign, nonatomic) UILabel *currentLocationLabel;
@property (assign, nonatomic) CLLocationManager *locMan;

- (IBAction)dropEMP:(id)sender;
- (IBAction)armEMP:(id)sender;

@end

这个.m文件:
#import "RobotWarsViewController.h"

@implementation RobotWarsViewController


@synthesize locMan;
@synthesize currentLocationView;
@synthesize currentLocationLabel;

- (void)viewDidLoad {
[super viewDidLoad];

locMan = [[CLLocationManager alloc] init];
// locMan.delegate = self;

}

- (IBAction)dropEMP:(id)sender{

NSLog(@"Boo");

}

- (IBAction)armEMP:(id)sender{

NSLog(@"boo");

}

- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation {

NSLog(@"location update");

}



- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}

- (void)dealloc {
[super dealloc];
[currentLocationView release];
[currentLocationLabel release];

}

@end

最佳答案

您是否将CoreLocation框架添加到您的项目中?

展开Frameworks组,然后查看那里是否列出了CoreLocation。如果没有,请右键单击它并添加。

关于iphone - objective-c : strange error when init a variable declared in my header file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4355449/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com