steipete / Aspects

Delightful, simple library for aspect oriented programming in Objective-C and Swift.
https://twitter.com/steipete
MIT License
8.4k stars 1.26k forks source link

-[UIViewControllerWrapperView aspects__touchesBegan:withEvent:]: unrecognized selector sent to instance #61

Open fatuhoku opened 9 years ago

fatuhoku commented 9 years ago

Reproduction:

  1. Start a test project.
  2. Create a view controller with [UIViewController new]
  3. Hook into its touchesBegan:withEvent: method; do something (e.g. NSLog(@"hello"))
  4. Run the app and touch the view.

Expected:

hello should be printed

Actual:

Program crashes with:

-[UIViewControllerWrapperView aspects__touchesBegan:withEvent:]: unrecognized selector sent to instance 0x7fad8b975220
2015-09-06 14:36:10.575 FormSheetOverlayExperiment[51277:2624244] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewControllerWrapperView aspects__touchesBegan:withEvent:]: unrecognized selector sent to instance 0x7fad8b975220'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010f785c65 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010f41cbb7 objc_exception_throw + 45
    2   CoreFoundation                      0x000000010f78d0ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x000000010f6e313c ___forwarding___ + 988
    4   CoreFoundation                      0x000000010f6e2cd8 _CF_forwarding_prep_0 + 120
    5   UIKit                               0x000000010ff46050 forwardTouchMethod + 245
    6   CoreFoundation                      0x000000010f67bdec __invoking___ + 140
    7   CoreFoundation                      0x000000010f67bc42 -[NSInvocation invoke] + 290 
    8   FormSheetOverlayExperiment          0x000000010ec4b174 __ASPECTS_ARE_BEING_CALLED__ + 4212
    9   CoreFoundation                      0x000000010f6e2f4f ___forwarding___ + 495
    10  CoreFoundation                      0x000000010f6e2cd8 _CF_forwarding_prep_0 + 120
    11  UIKit                               0x000000010ff46050 forwardTouchMethod + 245
    12  UIKit                               0x000000010fe107be -[UIWindow _sendTouchesForEvent:] + 325
    13  UIKit                               0x000000010fe11282 -[UIWindow sendEvent:] + 682
    14  UIKit                               0x000000010fdd7541 -[UIApplication sendEvent:] + 246
    15  UIKit                               0x000000010fde4cdc _UIApplicationHandleEventFromQueueEvent + 18265
    16  UIKit                               0x000000010fdbf59c _UIApplicationHandleEventQueue + 2066
    17  CoreFoundation                      0x000000010f6b9431 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    18  CoreFoundation                      0x000000010f6af2fd __CFRunLoopDoSources0 + 269
    19  CoreFoundation                      0x000000010f6ae934 __CFRunLoopRun + 868
    20  CoreFoundation                      0x000000010f6ae366 CFRunLoopRunSpecific + 470
    21  GraphicsServices                    0x0000000112a37a3e GSEventRunModal + 161
    22  UIKit                               0x000000010fdc28c0 UIApplicationMain + 1282
    23  FormSheetOverlayExperiment          0x000000010ec40e2f main + 111
    24  libdyld.dylib                       0x0000000111f7a145 start + 1
    25  ???                                 0x0000000000000001 0x0 + 1
steipete commented 9 years ago

UIKit has some of it's own magic in touch forwarding - do bot use with Aspects.

cheers, Peter

On 06 Sep 2015, at 15:41, Hok Shun Poon notifications@github.com wrote:

Reproduction:

Start a test project. Create a view controller with [UIViewController new] Hook into its touchesBegan:withEvent: method; do something (e.g. NSLog(@"hello")) Run the app and touch the view. Expected:

hello should be printed

Actual:

Program crashes with:

-[UIViewControllerWrapperView aspectstouchesBegan:withEvent:]: unrecognized selector sent to instance 0x7fad8b975220 2015-09-06 14:36:10.575 FormSheetOverlayExperiment[51277:2624244] *\ Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewControllerWrapperView aspectstouchesBegan:withEvent:]: unrecognized selector sent to instance 0x7fad8b975220' * First throw call stack: ( 0 CoreFoundation 0x000000010f785c65 exceptionPreprocess + 165 1 libobjc.A.dylib 0x000000010f41cbb7 objc_exception_throw + 45 2 CoreFoundation 0x000000010f78d0ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205 3 CoreFoundation 0x000000010f6e313c _forwarding_ + 988 4 CoreFoundation 0x000000010f6e2cd8 _CF_forwarding_prep_0 + 120 5 UIKit 0x000000010ff46050 forwardTouchMethod + 245 6 CoreFoundation 0x000000010f67bdec invoking_ + 140 7 CoreFoundation 0x000000010f67bc42 -[NSInvocation invoke] + 290 8 FormSheetOverlayExperiment 0x000000010ec4b174 ASPECTS_ARE_BEING_CALLED + 4212 9 CoreFoundation 0x000000010f6e2f4f forwarding** + 495 10 CoreFoundation 0x000000010f6e2cd8 _CF_forwarding_prep_0 + 120 11 UIKit 0x000000010ff46050 forwardTouchMethod + 245 12 UIKit 0x000000010fe107be -[UIWindow _sendTouchesForEvent:] + 325 13 UIKit 0x000000010fe11282 -[UIWindow sendEvent:] + 682 14 UIKit 0x000000010fdd7541 -[UIApplication sendEvent:] + 246 15 UIKit 0x000000010fde4cdc _UIApplicationHandleEventFromQueueEvent + 18265 16 UIKit 0x000000010fdbf59c _UIApplicationHandleEventQueue + 2066 17 CoreFoundation 0x000000010f6b9431 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 18 CoreFoundation 0x000000010f6af2fd CFRunLoopDoSources0 + 269 19 CoreFoundation 0x000000010f6ae934 __CFRunLoopRun + 868 20 CoreFoundation 0x000000010f6ae366 CFRunLoopRunSpecific + 470 21 GraphicsServices 0x0000000112a37a3e GSEventRunModal + 161 22 UIKit 0x000000010fdc28c0 UIApplicationMain + 1282 23 FormSheetOverlayExperiment 0x000000010ec40e2f main + 111 24 libdyld.dylib 0x0000000111f7a145 start + 1 25 ??? 0x0000000000000001 0x0 + 1 ― Reply to this email directly or view it on GitHub.