EnumeratorKit icon indicating copy to clipboard operation
EnumeratorKit copied to clipboard

map breaks with NSOrderedSetArrayProxy in EK 1.0.0

Open jeanetienne opened this issue 9 years ago • 2 comments

Problem with map:

The property is declared as a NSArray, debugging shows that the property is actually backed by a __NSOrderedSetArrayProxy.

Calling map: on this property crashes with following stack trace:

2015-03-17 13:51:13.225 XXXX[38091:696426] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSArray initWithObjects:count:]: method only defined for abstract class.  Define -[__NSOrderedSetArrayProxy initWithObjects:count:]!'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010f443a75 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010f0dcbb7 objc_exception_throw + 45
    2   CoreFoundation                      0x000000010f44b75f __CFRequireConcreteImplementation + 271
    3   CoreFoundation                      0x000000010f436157 -[NSArray initWithObjects:count:] + 39
    4   CoreFoundation                      0x000000010f33af92 -[NSArray initWithArray:range:copyItems:] + 450
    5   XXXX                                0x000000010c5d92e5 -[NSArray(EKEnumerable) initWithEnumerable:] + 261
    6   XXXX                                0x000000010c5d2d46 -[EKEnumerable map:] + 294
    7   XXXX                                0x000000010c4c78f0 -[XXX xxx:] + 384
    8   XXXX                                0x000000010c4d739f -[XXX xxx] + 303
    9   XXXX                                0x000000010c4d7bfd -[XXX xxx:] + 525
    10  UIKit                               0x000000010d8c5a22 -[UIApplication sendAction:to:from:forEvent:] + 75
    11  UIKit                               0x000000010d9cce50 -[UIControl _sendActionsForEvents:withEvent:] + 467
    12  UIKit                               0x000000010d9cc21f -[UIControl touchesEnded:withEvent:] + 522
    13  UIKit                               0x000000010dc73e80 _UIGestureRecognizerUpdate + 9487
    14  UIKit                               0x000000010d90b856 -[UIWindow _sendGesturesForEvent:] + 1041
    15  UIKit                               0x000000010d90c483 -[UIWindow sendEvent:] + 667
    16  UIKit                               0x000000010d8d8fb1 -[UIApplication sendEvent:] + 246
    17  UIKit                               0x000000010d8e6227 _UIApplicationHandleEventFromQueueEvent + 17700
    18  UIKit                               0x000000010d8c123c _UIApplicationHandleEventQueue + 2066
    19  CoreFoundation                      0x000000010f378c91 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    20  CoreFoundation                      0x000000010f36eb5d __CFRunLoopDoSources0 + 269
    21  CoreFoundation                      0x000000010f36e194 __CFRunLoopRun + 868
    22  CoreFoundation                      0x000000010f36dbc6 CFRunLoopRunSpecific + 470
    23  GraphicsServices                    0x0000000112441a58 GSEventRunModal + 161
    24  UIKit                               0x000000010d8c4580 UIApplicationMain + 1282
    25  FIAT                                0x000000010c49da29 main + 169
    26  libdyld.dylib                       0x000000010f9cd145 start + 1
    27  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

jeanetienne avatar Mar 17 '15 03:03 jeanetienne

Same issue occurs after calling map: on an array returned by a Core Data fetch, which is actually a _PFBatchFaultingArray

matt2e avatar Mar 23 '15 18:03 matt2e

Also occurs for mapping over an NSMutableArray. Interestingly, the concrete class in this case was __CFArray (rather than__CFMutableArray).

Creating a new (immutable) array with the contents of the original, then mapping over the result, solved this problem.

This is probably a problem with NSArray/NSMutableArray being class clusters - the actual exception being thrown was that initWithCapacity: was only defined for the abstract class NSMutableArray.

alaroldai avatar Sep 08 '15 01:09 alaroldai