在addactionset崩溃到HMEventTrigger

时间:2015-09-16 11:35:52

标签: ios ios9 homekit ios-homekit

将操作集添加到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

上遇到了错误的访问问题

1 个答案:

答案 0 :(得分:0)

我有完全相同的问题。我发现,如果我在之前将HMEventTrigger添加到HMHome ,我就会调用addActionSet:completionHandler:然后就可以了!

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