Xcode说变量" beacon"未申报?

时间:2014-06-08 01:44:46

标签: ios objective-c xcode ibeacon

- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated]
[[self.locationManager startRangingBeaconsInRegion: self.rangedRegion]
]}

- (void)viewDidDisappear:(BOOL)animated {
[super viewDidAppear:animated]
[[self.locationManager stopRangingBeaconsInRegion: self.rangedRegion]
]}

- (void)viewDidLoad
{
[super viewDidLoad];
self.tagname.text = [self.TagDetail objectForKey:@"Name"];
self.title = [self.TagDetail objectForKey:@"Name"];

NSString *proximity = @"near";


if ([beacon.proximity == CLProximityNear:]) {
    NSLog(@"Show near");
    [self.near setHidden:(NO)];
    [self.far setHidden:(YES)];
    [self.immediate setHidden:(YES)];




 }
else if ([beacon.proximity == CLProximityFar]) {  
    NSLog(@"Show");
    [self.near setHidden:(YES)];
    [self.far setHidden:(NO)];
    [self.immediate setHidden:(YES)];

}
else if ([beacon.proximity == CLProximityImmediate]) {
    NSLog(@"Show");
    [self.near setHidden: (YES)];
    [self.far setHidden: (YES)];
    [self.immediate setHidden: (NO)];

}

继承人.h文件

@interface TagDetailViewController : UIViewController
@property (nonatomic, strong) PFObject* TagDetail;
@property (strong, nonatomic)IBOutlet UILabel *tagname;
@property (nonatomic, strong)IBOutlet UIImageView *immediate;
@property (nonatomic, strong)IBOutlet UIImageView *near;
@property (nonatomic, strong)IBOutlet UIImageView *far;
@property (nonatomic, strong)IBOutlet UIButton *showOnMap;
@property CLLocationManager *locationManager;
@property CLBeaconRegion *rangedRegion;
@property NSUUID *artemisUUID;
@property CLBeaconMajorValue *major;
@property CLBeaconMinorValue *minor;
@property CLBeacon *proximity;

@end

它告诉我未识别变量信标,但在头文件中这样做* beacon不会删除任何错误。我究竟做错了什么?我对这种语言真的很陌生,所以这是我遇到错误的主要原因,但是我无法想象这一点。

1 个答案:

答案 0 :(得分:4)

您没有名为beacon的变量,您有一个名为CLBeacon的{​​{1}}对象。