1

将操作集添加到 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 行遇到了错误的访问问题

4

1 回答 1

0

我有完全相同的问题。我发现,如果我在调用之前HMEventTrigger添加了,那么它就起作用了!HMHome addActionSet:completionHandler:

home.addTrigger(beaconTrigger) { (error) -> Void in
     beaconTrigger.addActionSet(actionSet) { (error) -> Void in
...
于 2016-02-24T21:21:58.850 回答