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

Protocols and forwardingTargetForSelector:


  • Subject: Protocols and forwardingTargetForSelector:
  • From: "email@hidden" <email@hidden>
  • Date: Tue, 25 Feb 2014 14:42:34 +0000

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?
And what happens with synthesis for properties declared in protocols?

@interface DBManagedString : NSString

- (id)initWithMonoString:(MonoString *)monoString;
- (MonoString *)representedMonoString;

@end

@implementation DBManagedString
- (id)forwardingTargetForSelector:(SEL)aSelector
{
#pragma unused(aSelector)
    if (!self.forwardingTarget) {
        self.forwardingTarget = [DBManagedObject objectWithMonoObject:(MonoObject *)self.representedMonoString];
    }

    return self.forwardingTarget;
}
@end

Jonathan












_______________________________________________

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: Greg Parker <email@hidden>
  • Prev by Date: Re: exporting image files to disk using CGImageDestination
  • Next by Date: tableView - message sent to deallocated instance
  • Previous by thread: Re: exporting image files to disk using CGImageDestination
  • Next by thread: Re: Protocols and forwardingTargetForSelector:
  • Index(es):
    • Date
    • Thread