在一个目标中扩展UIScrollView . 在UITableView实例中使用扩展方法将在另一个目标中崩溃

在Cocoa Touch Framework Target中 . 我将以下方法添加到UIScrollView .

public extension UIScrollView {

  public func beginRefresh() {
    print("beginRefresh")
  }

  public func endRefresh() {
    print("endRefresh")
  }

}

在iOS App Target中作为演示应用程序 . 我在UITableView实例上调用这些方法 . 它崩溃了 .

override func viewDidLoad() {
    super.viewDidLoad()

    tableView.beginRefresh()
}

崩溃日志:

2016-08-10 16:22:29.736 DTRefresh iOS示例[7373:210619] - [UITableView beginRefresh]:无法识别的选择器发送到实例0x7fc91b019e00 2016-08-10 16:22:29.751 DTRefresh iOS示例[7373:210619] *由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:' - [UITableView beginRefresh]:无法识别的选择器发送到实例0x7fc91b019e00'*第一次抛出调用堆栈:(0 CoreFoundation 0x0000000109c39d85 exceptionPreprocess 165 1 libobjc.A.dylib 0x000000010b9dddeb objc_exception_throw 48 2 CoreFoundation 0x0000000109c42d3d - [NSObject的(NSObject的)doesNotRecognizeSelector:] 205 3的CoreFoundation 0x0000000109b88cfa __forwarding 970 4的CoreFoundation 0x0000000109b888a8 _CF_forwarding_prep_0 120 5 DTRefresh iOS示例0x0000000109a54a81 TFC21DTRefresh_iOS_Example18ListViewController11viewDidLoadfT_T 561 6 DTRefresh iOS示例0x0000000109a54b22 TToFC21DTRefresh_iOS_Example18ListViewController11viewDidLoadfT_T 34 7的UIKit 0x000000010a5fc984 - [UIView的控制器loadViewIfRequired] 1198 8的UIKit 0x000000010a5fccd3 - [UIViewController的视图] 27 9的UIKit 0x000000010a4d2fb4 - [一个UIWindow addRootViewControllerViewIfPossible] 61 10的UIKit 0x000000010a4d369d - [一个UIWindow _setHidden:强制:] 282 11的UIKit 0x00000001193a5d16 - [UIWindowAccessibility _orderFrontWithoutMakingKey] 68 12的UIKit 0x000000010a4e5180 - [的UIWindow makeKeyAndVisible ] 42 13的UIKit 0x000000010a459ed9 - [UIApplication的_callInitializationDelegatesForMainScene:transitionContext:] 4131 14的UIKit 0x000000010a460568 - [UIApplication的_runWithMainScene:transitionContext:完成:] 1769 15的UIKit 0x000000010a45d714 - [UIApplication的workspaceDidEndTransaction:] 188个16 FrontBoardServices 0x000000010d86e8c8 FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK 24个17 FrontBoardServices 0x000000010d86e741 - [FBSSerialQueue _performNext ] 178 18 FrontBoardServices 0x000000010d86eaca - [FBSSerialQueue _performNextFromRunLoopSource] 45 19 CoreFoundation 0x0000000109b5f301 CFRUNLOOP_IS_CALLING_OUT _TO_A_SOURCE0_PERFORM_FUNCTION 17 20的CoreFoundation 0x0000000109b5522c __CFRunLoopDoSources0 556 21的CoreFoundation 0x0000000109b546e3 __CFRunLoopRun 867 22的CoreFoundation 0x0000000109b540f8 CFRunLoopRunSpecific 488 23的UIKit 0x000000010a45cf21 - [UIApplication的_run] 402 24的UIKit 0x000000010a461f09 UIApplicationMain 171 25 DTRefresh iOS示例0x0000000109a54662主114 26 libdyld.dylib 0x000000010c4a192d开始1 27 ??? 0x0000000000000001 0x0 1)libc abi.dylib:以NSException类型的未捕获异常终止

回答(0)