我正在使用 Kontakt 信标和 iOS SDK,并且我的代码一次又一次地崩溃以获取我的信标的操作
Kontakt SDK 文档在这里
- (void)locationManager:(KTKLocationManager *)locationManager
didRangeBeacons:(NSArray *)beacons {
NSMutableDictionary *beaconsData = [NSMutableDictionary new];
for (CLBeacon *beacon in beacons) {
KTKBeacon *beaconData = [self _getDataForBeacon:beacon];
if (beaconData) [beaconsData setObject:beaconData forKey:beacon];
}
self.actionManager = [KTKActionManager new];
self.actionManager.delegate = self;
[self.actionManager processBeacons:beacons withData:beaconsData];
}
获取信标数据的方法
-(NSDictionary *)_getDataForBeacon:beacon
{
NSLog(@"%@",beacon);
NSData * jsonData = [NSData dataWithContentsOfURL:[NSURL
URLWithString:@"****"]];
NSError * error=nil;
NSDictionary *dic = [NSJSONSerialization
JSONObjectWithData:jsonData options:kNilOptions error:&error];
NSLog(@"%@",dic);
NSArray *array = [NSArray arrayWithObject:beacon];
NSDictionary *data = [self.client getActionsForBeacons:array changedSince:0 error:&error]; //##It crashes here##
NSLog(@"%@",data);
return data;
}
dic词典 的内容
{
"id" : "42152577-e3d2-4687-b499-8112402b2ca2",
"major" : 56809,
"txPower" : 3,
"browserActions" : [
],
"serial" : "",
"uniqueId" : "OFSP",
"interval" : 350,
"urlRequestActions" : [
],
"minor" : 57237,
"masterPassword" : null,
"password" : null,
"alias" : null,
"venue" : {
"id" : "f7fe1874-c9c2-4f88-980b-876681e2eb18",
"description" : "Flat room",
"rates" : [
],
"users" : [
],
"managers" : [
],
"priv" : true,
"beacons" : [
],
"lat" : null,
"beaconsCount" : 1,
"lng" : null,
"coverType" : null,
"name" : "Home"
},
"contentActions" : [
{
"actionType" : "CONTENT",
"beacon" : null,
"distance" : null,
"id" : "b0897c61-55c3-49c9-9f23-538f279ca1ce",
"owner" : {
"venues" : [
],
"password" : null,
"active" : false,
"id" : "307d0ef9-7207-47ec-980f-9382cff9b773",
"company" : {
"id" : "c95cc0fc-70fb-4a82-960c-c91845654fc8",
"name" : "Shubhank Gaur",
"key" : null
},
"email" : "shubhank008pp@gmail.com",
"salt" : null
},
"contentType" : "image\/jpeg",
"contentLength" : 354008,
"impairmentTypes" : [
],
"proximity" : "IMMEDIATE",
"contentCategory" : "IMAGE"
}
],
"proximity" : "f7826da6-4fa2-4e98-8024-bc5b71e0893e",
"name" : "Kontakt",
"actionsCount" : 1
}
最后这是错误
2014-07-24 17:52:10.249 Code64Beacons[371:60b]-[CLBeacon 标识符]:无法识别的选择器发送到实例 0x15593ef0 2014-07-24 17:52:10.250 Code64Beacons[371:60b] * 由于未捕获而终止应用程序exception 'NSInvalidArgumentException', reason: '-[CLBeacon identifier]: unrecognized selector sent to instance 0x15593ef0' * First throw call stack: (0x30d00f0b 0x3b497ce7 0x30d04837 0x30d03137 0x30c52098 0xaa41b 0xa60b9 0xa5bd7 0xa85bf 0x311c5e91 0x311c0aeb 0x311ba081 0x30ccc01d 0x30ccb397 0x30cca001 0x30c34769 0x30c3454b 0x35ba16d3 0x33593891 0xa52cd 0x3b995ab7) libc++abi.dylib:以 NSException (lldb) 类型的未捕获异常终止