Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 12. Properties > More About @dynamic

More About @dynamic

The opposite of @synthesize is @dynamic. When you specify @dynamic for a property, the compiler expects you to supply your own implementation of the accessor methods for that property. If you don’t, you’ll get a warning at compile time, and then an error at runtime when you try to use the property.

Why would you want to write the accessor methods when the compiler can do the work for you? The compiler only synthesizes relatively simple accessors that just set or return the property. Sometimes, you may need to do more. You might need to take some other actions when a property is set. For example, you might want to filter the input to make sure the property being set stays within an acceptable range.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint