• 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
What does the CLANG_WARN_OBJC_RECEIVER_WEAK warning protect us from?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

What does the CLANG_WARN_OBJC_RECEIVER_WEAK warning protect us from?


  • Subject: What does the CLANG_WARN_OBJC_RECEIVER_WEAK warning protect us from?
  • From: David Hoerl <email@hidden>
  • Date: Tue, 25 Feb 2014 10:23:52 -0500

I was perusing my warning options in Xcode, looking for "-Wunreachable-code" (which does not appear as a selectable option), when I saw this option in the "Objective C and ARC" options list:

  CLANG_WARN_OBJC_RECEIVER_WEAK
  Description: Warn about sending messages to Objective-C pointers
  that  are __weak.  This aids in avoiding situations (e.g., race
  conditions) when the last strong reference goes away and a client is
  messaging a __weak pointer that can suddenly (and unexpectedly)
  become nil.

  [CLANG_WARN_OBJC_RECEIVER_WEAK, -Wreceiver-is-weak]

My understanding from reading previous posts here was that if I use a weak object as a message receiver, that essentially that object is retained when the message is sent, and unretained when it returns - thus insuring that the object is kept alive while used within the method.

Did I misunderstand this - can an object "disappear" in the middle of a method? If the answer is no, then why the warning? A sister warning, "CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK", warns on repeated use of a weak object within a method.

David
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: What does the CLANG_WARN_OBJC_RECEIVER_WEAK warning protect us from?
      • From: Quincey Morris <email@hidden>
  • Prev by Date: iconutil corrupting alpha channel
  • Next by Date: Re: What does the CLANG_WARN_OBJC_RECEIVER_WEAK warning protect us from?
  • Previous by thread: Re: iconutil corrupting alpha channel
  • Next by thread: Re: What does the CLANG_WARN_OBJC_RECEIVER_WEAK warning protect us from?
  • Index(es):
    • Date
    • Thread