簡體   English   中英

通過Perform Crasher調用#selector @objc函數

[英]Calling #selector @objc function through perform crasher

我正在通過另一個視圖控制器調用一個函數:

perform(#selector(MainScreenViewController().test))

該動作稱為test,它位於MainScreenViewController() 到達此代碼后,應用程序將崩潰,並顯示以下崩潰報告:

2018-01-20 13:24:46.800692+0100 Business Name[40750:3947268] -[Business_Name.RPLabel test]: unrecognized selector sent to instance 0x7fd444d03e30
2018-01-20 13:24:46.809915+0100 Business Name[40750:3947268] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Business_Name.RPLabel test]: unrecognized selector sent to instance 0x7fd444d03e30'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001127621cb __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010de9af41 objc_exception_throw + 48
    2   CoreFoundation                      0x00000001127e2914 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
    3   UIKit                               0x000000010f5810bd -[UIResponder doesNotRecognizeSelector:] + 295
    4   CoreFoundation                      0x00000001126e5178 ___forwarding___ + 1432
    5   CoreFoundation                      0x00000001126e4b58 _CF_forwarding_prep_0 + 120
    6   Business Name                       0x000000010d54edc2 _T013Business_Name7RPLabelC5setupyyF + 738
    7   Business Name                       0x000000010d54e705 _T013Business_Name7RPLabelCACSC6CGRectV5frame_tcfc + 325
    8   Business Name                       0x000000010d54e746 _T013Business_Name7RPLabelCACSC6CGRectV5frame_tcfcTo + 38
    9   UIKit                               0x000000010f3f3f66 -[UIView init] + 62
    10  Business Name                       0x000000010d5385a3 _T0So7UILabelCABycfcTO + 19
    11  Business Name                       0x000000010d53137c _T0So7UILabelCABycfC + 60
    12  Business Name                       0x000000010d538944 globalinit_33_2857E66F75A5DBE934F5CCD1167A060E_func5 + 20
    13  libdispatch.dylib                   0x000000011380f43c _dispatch_client_callout + 8
    14  libdispatch.dylib                   0x00000001138109c7 dispatch_once_f + 297
    15  Business Name                       0x000000010d538984 _T013Business_Name9mainTitleAA7RPLabelCfau + 36
    16  Business Name                       0x000000010d5389ae _T013Business_Name10setupTitleyyF + 30
    17  Business Name                       0x000000010d53fd1f _T013Business_Name24MainScreenViewControllerC13viewDidAppearySbF + 31
    18  Business Name                       0x000000010d53fe23 _T013Business_Name24MainScreenViewControllerC13viewDidAppearySbFTo + 51
    19  UIKit                               0x000000010f4fcaaf -[UIViewController _setViewAppearState:isAnimating:] + 699
    20  UIKit                               0x000000010f55b746 -[UITabBarController viewDidAppear:] + 115
    21  UIKit                               0x000000010f4fcaaf -[UIViewController _setViewAppearState:isAnimating:] + 699
    22  UIKit                               0x000000010f4ff959 __64-[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]_block_invoke + 42
    23  UIKit                               0x000000010f4fdc4d -[UIViewController _executeAfterAppearanceBlock] + 86
    24  UIKit                               0x000000010f364d9d _runAfterCACommitDeferredBlocks + 634
    25  UIKit                               0x000000010f35330d _cleanUpAfterCAFlushAndRunDeferredBlocks + 280
    26  UIKit                               0x000000010f374714 __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 155
    27  CoreFoundation                      0x000000011270520c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    28  CoreFoundation                      0x00000001126e9a3b __CFRunLoopDoBlocks + 203
    29  CoreFoundation                      0x00000001126e9214 __CFRunLoopRun + 1300
    30  CoreFoundation                      0x00000001126e8a89 CFRunLoopRunSpecific + 409
    31  GraphicsServices                    0x000000011556e9c6 GSEventRunModal + 62
    32  UIKit                               0x000000010f358d30 UIApplicationMain + 159
    33  Business Name                       0x000000010d548637 main + 55
    34  libdyld.dylib                       0x000000011388bd81 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

這是測試中的代碼:

@objc func test(){
    print("test")
}
MainScreenViewController().perform(#selector(MainScreenViewController().test))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM