• 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: Stupid objective-c question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stupid objective-c question


  • Subject: Re: Stupid objective-c question
  • From: Uli Kusterer <email@hidden>
  • Date: Sat, 24 Sep 2016 04:25:58 +0200

> On 22 Sep 2016, at 03:21, Slipp Douglas Thompson <email@hidden> wrote:
>
>
>> On Sep 21, 2016, at 8:00 PM, Slipp Douglas Thompson <email@hidden> wrote:
>>
>>> On Sep 21, 2016, at 17:01 , Graham Cox <email@hidden> wrote:
>>>>
>>>> This should be: if([(NSString*)context isEqualToString:@“mediaLibraryLoaded”])…
>>>
>>> Actually, this is not a good idea either, because *other* observations — ones you don’t control — might use a value that’s not an object, or not even a valid pointer.
>>
>
> I see your point about context plausibly not being neither an NSObject nor nil.  While you could check if context is an NSObject beforehand (is there even a reliable way to do this?  CocoaWithLove <http://www.cocoawithlove.com/2010/10/testing-if-arbitrary-pointer-is-valid.html> couldn't find a great approach ;-/)— I think coding consistently against all other addObserver: calls in your app is a good-enough solution.  I.E. If you implement observeValueForKeyPath: with [context isEqual: …] checks, make sure all the other addObserver: calls (for those same keys, at least) are using nil or NSObjects.

That's not enough. You would also have to ensure that none of Apple's code uses a non-object context in any KVOs it installs on any of your objects.

Which you can't.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de


_______________________________________________

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


References: 
 >Stupid objective-c question (From: Gabriel Zachmann <email@hidden>)
 >Re: Stupid objective-c question (From: Graham Cox <email@hidden>)
 >Re: Stupid objective-c question (From: Quincey Morris <email@hidden>)
 >Re: Stupid objective-c question (From: Slipp Douglas Thompson <email@hidden>)
 >Re: Stupid objective-c question (From: Slipp Douglas Thompson <email@hidden>)

  • Prev by Date: Re: Stupid objective-c question
  • Next by Date: Re: Stupid objective-c question
  • Previous by thread: Re: Stupid objective-c question
  • Next by thread: Re: Stupid objective-c question
  • Index(es):
    • Date
    • Thread