Defining handleUnknownMessage:withContext: on NSObject does not make it work on all NSObject subclasses #15

alloy opened this Issue Jan 5, 2011 · 2 comments


None yet
1 participant

alloy commented Jan 5, 2011

This probably means that these problematic classes override handleUnknownMessage:withContext: and do not call super.

These classes include, but may not be limited to:

  • NuCell
  • NSNull
  • NSArray

I'll take a look at this myself, but I've created this ticket as a reminder, as I'll have to do a concise pass over the complete source to see what other classes might need to be fixed as well.

alloy commented Jan 8, 2011

I've been playing with this and made it work for NuCell & NSArray:

However, the same ‘problem’ applies to NSDictionary, but I haven't been able to think of a way to make it work for that case. The problem is that sending an unknown symbol message which is also not a key in the dictionary currently returns nil, which is consistent with the valueForKey: behavior. I.e. This would be really confusing if this would suddenly return different values, or even raise an unknown handler exception.

Regarding NSNull, none of my naive attempts have allowed me to catch unknown messages.

alloy commented Jan 8, 2011

Oops, just saw that when running the complete test suite this assertion in fails:

(assert_equal 'nada (match 0 (nil 'zilch) (x 'nada)))

This is because of the dummy NSObject handleUnknownMessage:withContext: method I defined in and Will have to think about a better way to test it…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment