我是使用Twilio的新手,我希望有人可以帮助我调试我的应用。
我正在打电话来获取一个能力令牌,它返回就好了。我在控制台中打印它以检查当我调用initWithCapabilityToken时,它出现了什么东西正在破坏,我无法弄明白。
这是我的代码......
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:
^(NSURLResponse *response, NSData *data, NSError *error){
// Log Any Reply
if ([data length] >0 && error == nil) {
NSData *jsonData = data;
// Deserialize JSON into Dictionary
error = nil;
id jsonObject = [NSJSONSerialization JSONObjectWithData:jsonData
options:NSJSONReadingAllowFragments
error:&error ];
if (jsonObject != nil && error == nil) {
NSLog(@"Successfully deserialized JSON response...");
if ([jsonObject isKindOfClass:[NSDictionary class]]) {
NSDictionary *deserializedDictionary = (NSDictionary *)jsonObject;
NSLog(@"Deserialized JSON Dictionary = %@", deserializedDictionary);
NSString *token = [deserializedDictionary objectForKey:@"token"];
if (token == nil) {
NSLog(@"Error retrieving token");
} else {
NSLog(@"Token: %@", token);
// Setup TCDevice
_phone = [[TCDevice alloc] initWithCapabilityToken:token delegate:self];
}
}
} else if (error != nil){
NSLog(@"An error happened while de-serializing the JSON data.");
}
}else if ([data length] == 0 && error == nil){
NSLog(@"Nothing was downloaded.");
}else if (error != nil){
NSLog(@"Error happened = %@", error);
}
}];
这是我在记录令牌后立即得到的内容......
2015-01-29 16:32:14.637 AppName[4649:701822] +[NSString stringWithPJStr:]: unrecognized selector sent to class 0x3377da98
2015-01-29 16:32:14.639 AppName[4649:701822] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSString stringWithPJStr:]: unrecognized selector sent to class 0x3377da98'
*** First throw call stack:
(0x254da49f 0x32c90c8b 0x254df7d5 0x254dd7d7 0x2540f058 0x10ee7d 0x10e32b 0x10e2b7 0x105959 0x10568d 0x7b3ab 0x24fa228d 0x261d52b1 0x2614034d 0x26132b07 0x261d7c1b 0x487e29 0x4822c9 0x489567 0x48a891 0x33351e31 0x33351b84)
libc++abi.dylib: terminating with uncaught exception of type NSException
由于
答案 0 :(得分:4)
在阅读完所有Twilios文档后,我发现我遗漏了一件事。我不得不将-ObjC添加到Other Linker Flags并解决了我的问题。
答案 1 :(得分:1)
将此行添加到其他链接器标志:
-ObjC
-lTwilioClient
-lcrypto
-lssl
它只适用于上面的C添加结束(-ObjC)
答案 2 :(得分:0)
你正在调用一个不存在的stringWithPJStr函数(选择器)。