cocoa - Can a category implement a protocol in Objective C? -


i have category on nsdate , convenient if implement protocol created. possible? what's correct syntax this?

yes, that's possible. syntax is:

@interface nsdate (categoryname) <protocolname> @end  @implementation nsdate (categoryname) @end 

here's apple's documentation on topic.

it's possible using class extension. privately conform delegate protocols. doing hides implementation detail of being delegate of class public interface , removes dependency header.


Comments