• 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: Protocols and forwardingTargetForSelector:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Protocols and forwardingTargetForSelector:


  • Subject: Re: Protocols and forwardingTargetForSelector:
  • From: Greg Parker <email@hidden>
  • Date: Tue, 25 Feb 2014 13:38:21 -0800

On Feb 25, 2014, at 6:42 AM, email@hidden wrote:
> I have an NSString subclass as below.
> If the subclass doesn’t respond to a given selector I want to forward the selector to another object.
>
> What is the best way to declare the interfaces for DBManagedString and DBManagedObject?
>
> Should I declare a DBManagedObject protocol in which all the methods are optional?

A protocol works.

Declaring the methods without implementing them also works.

For properties you can use @dynamic to tell the compiler that the property's implementation is handled elsewhere (via forwarding, in your case).


> And what happens with synthesis for properties declared in protocols?

Nothing. The class implementation must have some explicit code to get a property implementation. Merely conforming to a protocol never adds code to your class.


--
Greg Parker     email@hidden     Runtime Wrangler



_______________________________________________

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


  • Follow-Ups:
    • Re: Protocols and forwardingTargetForSelector:
      • From: "email@hidden" <email@hidden>
References: 
 >Protocols and forwardingTargetForSelector: (From: "email@hidden" <email@hidden>)

  • Prev by Date: tableView - message sent to deallocated instance
  • Next by Date: Re: Protocols and forwardingTargetForSelector:
  • Previous by thread: Protocols and forwardingTargetForSelector:
  • Next by thread: Re: Protocols and forwardingTargetForSelector:
  • Index(es):
    • Date
    • Thread