Hello, In using the nifty Parcoa Library[1] with GNUstep, I ran into an incompatibility causing a crash. It turns out GNUstep's current implementation of NSMutableArray setObject atIndexedSubscript is missing a bit of functionality to be on par with Apple's documented API[2].
I've created a pull request[3] adding the missing functionality, and also included the patch below. Would someone be willing to merge this in? Alternatively, any feedback on the patch would be appreciated. Thank you, Patryk [1] https://github.com/brotchie/Parcoa [2] https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/#//apple_ref/occ/instm/NSMutableArray/setObject:atIndexedSubscript: [3] https://github.com/gnustep/base/pull/2 diff --git a/Source/NSArray.m b/Source/NSArray.m index ab1cc92..9863abb 100644 --- a/Source/NSArray.m +++ b/Source/NSArray.m @@ -2055,9 +2055,18 @@ compare(id elem1, id elem2, void* context) [self subclassResponsibility: _cmd]; } +/** + * Sets the object at the index with the passed object, adding the object + * to the end of the array (growing it) if the passed index is equal to + * the current count. + */ - (void) setObject: (id)anObject atIndexedSubscript: (size_t)anIndex { - [self replaceObjectAtIndex: (NSUInteger)anIndex withObject: anObject]; + if ([self count] == anIndex) { + [self addObject: anObject]; + } else { + [self replaceObjectAtIndex: (NSUInteger)anIndex withObject: anObject]; + } } /** Replaces the values in the receiver at the locations given by the
_______________________________________________ Discuss-gnustep mailing list [email protected] https://lists.gnu.org/mailman/listinfo/discuss-gnustep
