0
votes

I want to make a new object from string access_token. I've made a Token:NSObject (.h + .m) and I'm trying to setAccessToken and show it in the NSLog. This is the code in my LoginViewController.m:

NSString *token = responseObject[@"access_token"];

        Token *t = [[Token alloc]init];
        [t setAccessToken:token];
        NSLog(t);

And this is the error i get:

Create[29485:770358] -[Token _fastCStringContents:]: unrecognized selector sent to instance 0x7f8e815d0780 Create[29485:770358] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Token _fastCStringContents:]: unrecognized selector sent to instance 0x7f8e815d0780' * First throw call stack: ( 0 CoreFoundation 0x000000010149ff45 exceptionPreprocess + 165 1 libobjc.A.dylib
0x0000000100f19deb objc_exception_throw + 48 2 CoreFoundation
0x00000001014a856d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205 3 CoreFoundation 0x00000001013f5eea ___forwarding_
+ 970 4 CoreFoundation 0x00000001013f5a98 _CF_forwarding_prep_0 + 120 5
libsystem_trace.dylib 0x00000001036e8327 os_log_shim_with_CFString + 120 6 CoreFoundation
0x000000010148ef24 _CFLogvEx3 + 132 7 Foundation
0x0000000100b9489e _NSLogv + 117 8 Foundation
0x0000000100ae40f2 NSLog + 152 9 Create
0x00000001004d665b 21-[LoginVC UserLogin:]_block_invoke + 203 10 Create 0x00000001004d7f18 __64-[AFHTTPRequestOperation setCompletionBlockWithSuccess:failure:]_block_invoke49 + 40 11 libdispatch.dylib 0x00000001033fde5d _dispatch_call_block_and_release + 12 12 libdispatch.dylib 0x000000010341e49b _dispatch_client_callout + 8 13 libdispatch.dylib 0x00000001034062af _dispatch_main_queue_callback_4CF + 1738 14 CoreFoundation 0x00000001014002e9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 9 15 CoreFoundation 0x00000001013c18a9 __CFRunLoopRun + 2073 16 CoreFoundation 0x00000001013c0e08 CFRunLoopRunSpecific + 488 17 GraphicsServices
0x00000001056dcad2 GSEventRunModal + 161 18 UIKit
0x000000010184c30d UIApplicationMain + 171 19 Create
0x00000001004d6a2f main + 111 20 libdyld.dylib
0x000000010345292d start + 1 21 ???
0x0000000000000001 0x0 + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException

Hope somebody can help me out!

1

1 Answers

1
votes

NSLog(...) function assumes the first argument is an instance of NSString. If you want to use a different object, either use:

NSLog([t description]) or a format string NSLog(@"%@", t).