All Projects → steipete → Pstdelegateproxy

steipete / Pstdelegateproxy

Licence: mit
A simple proxy that forwards optional methods to delegates - less boilerplate in your code!

PSTDelegateProxy

A simple proxy that forwards optional methods to delegates - less boilerplate in your code!

When calling optional delegates, the regular pattern is to check using respondsToSelector:, then actually call the method. This is straightforward and easy to understand:

    id<PSPDFResizableViewDelegate> delegate = self.delegate;
    if ([delegate respondsToSelector:@selector(resizableViewDidBeginEditing:)]) {
        [delegate resizableViewDidBeginEditing:self];
    }

What we really want is something like this:

    [self.delegateProxy resizableViewDidBeginEditing:self];

Read more on my blog: Smart Proxy Delegation

License

MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].