1

I have an issue while adding the action set to the HMEventTrigger. Below is my code. Any suggestions would be very helpful.

// 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)
 {

}

I am getting bad access issue at tr2 addactionset line

SRI
  • 1,514
  • 21
  • 39

1 Answers1

0

I had exactly the same problem. I found that if I added the HMEventTrigger to the HMHome before I called addActionSet:completionHandler: then it worked!

home.addTrigger(beaconTrigger) { (error) -> Void in
     beaconTrigger.addActionSet(actionSet) { (error) -> Void in
...
mharper
  • 3,212
  • 1
  • 23
  • 23