• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Seeing nil passed to isEqual:, despite non-null declaration
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Seeing nil passed to isEqual:, despite non-null declaration


  • Subject: Re: Seeing nil passed to isEqual:, despite non-null declaration
  • From: João Varela <email@hidden>
  • Date: Fri, 13 Jan 2017 19:42:39 +0000

Hi Sean

Yes, I was bitten by that too, very, very recently, when I was translating a few files into Swift and I got warning when I didn’t use an optional for the object of the method.

Actually, I suspect that’s a bug in the headers, or probably that’s a non-audited header for nullability.

Although isEqual: is part of the NSObject protocol and isEqualTo: is part of the NSComparisonMethods protocol of NSObject, the latter expects a nullable receiver (check that in NSScriptWhoseTests.h). Check the Swift version of it and you will see that isEqual(to: Any?) expects an optional. Therefore, I suspect that the same is true for isEqual: and that this API has not yet been audited for nullability.

Perhaps you should file a bug against that header.

João



>
>
> NSObject.h declares:
>
> - (BOOL)isEqual:(id)object;
>
> Note the parameter is not nullable.  And yet, I'm seeing nil passed to one of my class's overrides of isEqual: when I invoke Edit>Undo.  Backtrace:
>
> #4	-[RRLookupTable isEqual:]
> #5	-[NSManagedObject(_NSInternalMethods) _updateFromUndoSnapshot:] ()
> #6	-[NSManagedObjectContext(_NSInternalChangeProcessing) _undoInsertions:] ()
> #7	-[_NSUndoStack popAndInvoke] ()
> #8	-[NSUndoManager undoNestedGroup] ()
> #9	_os_activity_initiate ()
> #10	-[NSApplication(NSResponder) sendAction:to:from:] ()
> #11	-[NSMenuItem _corePerformAction] ()
> #12	-[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] ()
> #13	_os_activity_initiate ()
> #14	-[NSMenu performKeyEquivalent:] ()
> #15	routeKeyEquivalent ()
> #16	-[NSApplication(NSEvent) sendEvent:] ()
> #17	-[NSApplication run] ()
> #18	NSApplicationMain ()
> #19	main
>


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Prev by Date: Re: Seeing nil passed to isEqual:, despite non-null declaration
  • Next by Date: Re: Seeing nil passed to isEqual:, despite non-null declaration
  • Previous by thread: Re: Seeing nil passed to isEqual:, despite non-null declaration
  • Next by thread: Re: What should we do if file-opening takes a long time?
  • Index(es):
    • Date
    • Thread