Ios addactionset设置为HMEventTrigger时崩溃

Ios addactionset设置为HMEventTrigger时崩溃,ios,ios9,homekit,ios-homekit,Ios,Ios9,Homekit,Ios Homekit,将操作集添加到HMEventTrigger时出现问题。下面是我的代码。任何建议都会很有帮助 // Set-up a region CLLocationDegrees latitude = 17.4411482; CLLocationDegrees longitude = 78.3910691; CLLocationCoordinate2D centerCoordinate = CLLocationCoordinate2DMake(latitude, longitude); CLCircular

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

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

home.addTrigger(beaconTrigger) { (error) -> Void in
     beaconTrigger.addActionSet(actionSet) { (error) -> Void in
...

我也有同样的问题。我发现如果我在调用
addActionSet:completionHandler:
之前将
HMEventTrigger
添加到
HMHome
,那么它就工作了

home.addTrigger(beaconTrigger) { (error) -> Void in
     beaconTrigger.addActionSet(actionSet) { (error) -> Void in
...