我有一个问题,而添加动作集的HMEventTrigger。下面是我的代码。任何建议都会很有帮助的。
// Set-up a region
CLLocationDegrees latitude = 17.4411482;
CLLocationDegrees longitude = 78.3910691;
CLLocationCoordinate2D centerCoordinate = CLLocationCoordinate2DMake(latitude, longitude);
CLCircularRegion *region = [[CLCircularRegion alloc] initWithCenter:centerCoordinate
radius:2 // Metres
identifier:@"testLocation"];
region.notifyOnExit = YES;
region.notifyOnEntry = YES;
HMLocationEvent *ev = [[HMLocationEvent alloc] initWithRegion:region];
NSPredicate *pred = [HMEventTrigger predicateForEvaluatingTriggerWithCharacteristic:appDel.selectedCh relatedBy:NSEqualToPredicateOperatorType toValue:appDel.selectedCh.value];
HMEventTrigger *tr2 = [[HMEventTrigger alloc] initWithName:eventName.text events:[NSArray arrayWithObjects:ev,nil] predicate:pred];
HMActionSet *abcd = appDel.selectedHome.actionSets[0];
[tr2 addActionSet:abcd completionHandler:^(NSError *err)
{
}
我在tr2 addactionset line遇到访问问题
我也遇到了同样的问题。我发现,如果我在之前将HMEventTrigger
添加到HMHome
,我调用addActionSet:completionHandler:
,那么它就工作了!
home.addTrigger(beaconTrigger) { (error) -> Void in
beaconTrigger.addActionSet(actionSet) { (error) -> Void in
...