NSRangeException issue in quoted tweet @ Twitter Kit/iOS 2.8.1

ios

#1

Hello

I would report this issue in Twitter Kit/iOS 2.8.1.

[Case]
When below delegate function is implemented and click an image in quoted tweet, It causes NSRangeException in Twitter Kit library.

func tweetView(_ tweetView: TWTRTweetView, didTap image: UIImage, with imageURL: URL) {
    //print(tweetView.tweet
}
Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010bfd1b0b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010b393141 objc_exception_throw + 48
    2   CoreFoundation                      0x000000010bf0705b -[__NSArrayM objectAtIndex:] + 203
    3   TestApp                              0x000000010530d73a -[TWTRTweetMediaView imageAtIndex:] + 73
    4   TestApp                              0x00000001052dfdc3 -[TWTRTweetContentView imageForMediaEntity:] + 79
    5   TestApp                              0x0000000105309957 -[TWTRTweetView allowDelegateToHandlePresentationOfImageMediaEntity:] + 166
    6   TestApp                              0x00000001053097f4 -[TWTRTweetView tweetMediaView:shouldPresentImageForMediaEntity:] + 66
    7   TestApp                              0x000000010530e38d -[TWTRTweetMediaView shouldPresentMediaEntity:] + 142
    8   TestApp                              0x000000010530d89a -[TWTRTweetMediaView presentDetailedImageViewWithMediaEntityAtIndex:] + 143
    9   TestApp                              0x000000010530d4bb -[TWTRTweetMediaView presentDetailedViewForMediaEntityAtIndex:] + 112
    10  UIKit                               0x0000000108f6fc09 -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 57
    11  UIKit                               0x0000000108f77a07 _UIGestureRecognizerSendTargetActions + 109
    12  UIKit                               0x0000000108f753bb _UIGestureRecognizerSendActions + 225
    13  UIKit                               0x0000000108f7467e -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 981
    14  UIKit                               0x0000000108f60e02 _UIGestureEnvironmentUpdate + 1219
    15  UIKit                               0x0000000108f608f3 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] + 484
    16  UIKit                               0x0000000108f5faba -[UIGestureEnvironment _updateGesturesForEvent:window:] + 274
    17  UIKit                               0x0000000108aabb9a -[UIWindow sendEvent:] + 4092
    18  UIKit                               0x0000000108a587b0 -[UIApplication sendEvent:] + 352
    19  UIKit                               0x000000010923badc __dispatchPreprocessedEventFromEventQueue + 2926
    20  UIKit                               0x0000000109233a3a __handleEventQueue + 1122
    21  CoreFoundation                      0x000000010bf77c01 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    22  CoreFoundation                      0x000000010bf5d0cf __CFRunLoopDoSources0 + 527
    23  CoreFoundation                      0x000000010bf5c5ff __CFRunLoopRun + 911
    24  CoreFoundation                      0x000000010bf5c016 CFRunLoopRunSpecific + 406
    25  GraphicsServices                    0x000000010e7f9a24 GSEventRunModal + 62
    26  UIKit                               0x0000000108a3b0d4 UIApplicationMain + 159
    27  TestApp                              0x00000001051159c7 main + 55
    28  libdyld.dylib                       0x000000010d09165d start + 1
    29  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

#2

Thanks so much for this report. It’s on our radar and we’ll aim to have a fix in the next Twitter Kit release.