Sean Marraffa
Sean Marraffa

Reputation: 452

Twilio iOS unrecognized selector sent to Class

I'm new to using Twilio and I'm hoping someone can help me debug my app.

I am making a call to get a capability token and it is returned just fine. I print it in the console to check then it appears when I make the call to initWithCapabilityToken that's where something is breaking and I cant figure it out.

Here is my code...

[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);
     }
 }];

Here is what I get right after my token is logged...

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

Thanks

Upvotes: 3

Views: 691

Answers (3)

Sean Marraffa
Sean Marraffa

Reputation: 452

After reading all of Twilios documentation I discovered I was missing one thing. I had to add -ObjC to Other Linker Flags and that solved my problem.

Upvotes: 4

chrigu
chrigu

Reputation: 145

add this lines to the other linker flags:

-ObjC
-lTwilioClient
-lcrypto
-lssl

it worked for me only with a upper C add the end (-ObjC)

Upvotes: 1

SonicBison
SonicBison

Reputation: 790

Somewhere you are calling a stringWithPJStr function(selector) that doesn't exist.

Upvotes: 0

Related Questions