作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我添加以下行时,我得到:
locMan = [[CLLocationManager alloc] init];
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
#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/
我是一名优秀的程序员,十分优秀!