我已经完成了两个教程并且正在阅读基本的C.通过做最好的学习并在过去一周左右编写了一些轻量级的应用程序.我正在加快编写一些将使用ibeacon的应用程序.当我浏览一些示例并阅读参考指南时,我看到可以通过为每个UUID运行startMonitoringForRegion来扫描多个区域.好的,所以我想我可以为每个UUID运行它,但那不起作用.我确定我正在做一些基本上完全错误的事情......下面的代码是一个彻底的黑客攻击 - 一旦我得到语义,我将从带有API调用的数据库中提取UUID,然后循环遍历它们以激活监视.下面的代码导致最后一个循环只显示四个UUID中的两个.
在标题中:
@property (strong, nonatomic) CLBeaconRegion *myBeaconRegion;
@property (strong, nonatomic) CLBeaconRegion *myBeaconRegion2;
@property (strong, nonatomic) CLBeaconRegion *myBeaconRegion3;
@property (strong, nonatomic) CLBeaconRegion *myBeaconRegion4;
Run Code Online (Sandbox Code Playgroud)
在主要:
NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@"86E4BDEA-C6FF-442C-95CB-E6E557A23CF2"];
self.myBeaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:@"com.appcoda.testregion"];
NSUUID *uuid2 = [[NSUUID alloc] initWithUUIDString:@"C9AFF296-A722-4F2D-8669-47B7CCC79A14"];
self.myBeaconRegion2 = [[CLBeaconRegion alloc] initWithProximityUUID:uuid2 identifier:@"com.appcoda.testregion"];
NSUUID *uuid3 = [[NSUUID alloc] initWithUUIDString:@"1DBDDC7C-49BB-48BF-A2F6-A4825BD514EA"];
self.myBeaconRegion3 = [[CLBeaconRegion alloc] initWithProximityUUID:uuid3 identifier:@"com.appcoda.testregion"];
NSUUID *uuid4 = [[NSUUID alloc] initWithUUIDString:@"8D942B9E-0197-4C81-8722-92144599E9F7"];
self.myBeaconRegion4 = [[CLBeaconRegion alloc] initWithProximityUUID:uuid4 identifier:@"com.appcoda.testregion"];
[self.locationManager startMonitoringForRegion:self.myBeaconRegion];
[self.locationManager startMonitoringForRegion:self.myBeaconRegion2];
[self.locationManager startMonitoringForRegion:self.myBeaconRegion3];
[self.locationManager …Run Code Online (Sandbox Code Playgroud)