bugGNUSTEP System - Bugs: bug #19220, NSArray containsObject: and...


bug #19220: NSArray containsObject: and indexOfObject: do not invoke isEqual on array element

Submitted by:  Jonathan Olson <jpolson>
Submitted on:  Tue 06 Mar 2007 04:36:52 PM UTC  
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Tue 06 Mar 2007 04:36:52 PM UTC, original submission:

The NSArray class has a subtle incompatiblity with the Foundation class on Cocoa.
According to the Apple OSX documentation for containsObject:

This method determines whether anObject is present in the receiver by sending an isEqual: message to each of the receiver’s objects (and passing anObject as the parameter to each isEqual: message).

However, the GNUstep implementation instead invokes the isEqual: method on the parameter, passing the array element as the parameter to isEqual:. This causes subtle incompatibilities in applications which implement non-commutative isEqual: methods.

Attached is a test program illustrating this behavior. On OSX, this program returns YES for both containsObject: comparisons.

Jonathan Olson <jpolson>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Attached Files
file #12129:  test.m added by jpolson (827B - application/octet-stream)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by jpolson (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2007-03-06 jpolson Attached File- => Added test.m, #12129

    Back to the top

    Powered by Savane 3.3