无法记录我的setAccessToken

时间:2015-11-21 15:16:53

标签: ios objective-c afnetworking afnetworking-2 unrecognized-selector

我想从字符串access_token创建一个新对象。 我做了一个令牌:NSObject(.h + .m),我正在尝试setAccessToken并在NSLog中显示它。这是我的LoginViewController.m中的代码:

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

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

这是我得到的错误:

  

创建[29485:770358] - [令牌_fastCStringContents:]:无法识别   选择器发送到实例0x7f8e815d0780   创建[29485:770358] *因未捕获的异常而终止应用   'NSInvalidArgumentException',原因:' - [Token _fastCStringContents:]:   无法识别的选择器发送到实例0x7f8e815d0780'   * 第一次抛出调用堆栈:(0 CoreFoundation 0x000000010149ff45 exceptionPreprocess + 165 1 libobjc.A.dylib
  0x0000000100f19deb objc_exception_throw + 48 2 CoreFoundation
  0x00000001014a856d - [NSObject(NSObject)doesNotRecognizeSelector:] +   205 3 CoreFoundation 0x00000001013f5eea   ___转发_
+ 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基金会   0x0000000100b9489e _NSLogv + 117 8基金会   0x0000000100ae40f2 NSLog + 152 9创建
  0x00000001004d665b 21- [LoginVC UserLogin:] _ block_invoke + 203 10   创建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图形服务
  0x00000001056dcad2 GSEventRunModal + 161 18 UIKit
  0x000000010184c30d UIApplicationMain + 171 19创建
  0x00000001004d6a2f main + 111 20 libdyld.dylib
  0x000000010345292d开始+ 1 21 ???   0x0000000000000001 0x0 + 1)libc ++ abi.dylib:终止于   NSException类型的未捕获异常

希望有人可以帮助我!

1 个答案:

答案 0 :(得分:1)

NSLog(...)函数假定第一个参数是NSString的实例。如果要使用其他对象,请使用:

NSLog([t description])或格式字符串NSLog(@"%@", t)