Twilio iOS 无法识别的选择器已发送至 Class

Twilio iOS unrecognized selector sent to Class

我刚开始使用 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

谢谢

您在某处调用不存在的 stringWithPJStr 函数(选择器)。

阅读所有 Twilios 文档后,我发现我遗漏了一件事。我必须将 -ObjC 添加到其他链接器标志,这解决了我的问题。

将此行添加到其他链接器标志:

-ObjC
-lTwilioClient
-lcrypto
-lssl

它只对我有用,上面的 C 添加结尾 (-ObjC)