Skip to content

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

License

Notifications You must be signed in to change notification settings

bErKut/PSTDelegateProxy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Objective-C 100.0%