Using a Swift protocol in Objective-C -
i'm working on converting project objective-c swift, , swift class i'm using, have protocol
i'm trying access in objective-c class. problem is, delegate
not accessible in objective-c class. here swift class:
protocol ratebuttondelegate { func ratebuttonpressed(rating: int) } class ratebuttonview: uiview { var delegate: ratebuttondelegate? var divider1: uiview! var divider2: uiview! }
when @ myproject-swift.h
file, don't see delegate
:
@interface ratebuttonviewtest : uiview @property (nonatomic) uiview * divider1; @property (nonatomic) uiview * divider2; @end
and when seek utilize ratebuttonview.delegate
in objective-c class, compiler error.
anyone know issue? how access swift protocol in objective-c?
you need mark protocol @objc
attribute accessible objective-c:
@objc protocol ratebuttondelegate { func ratebuttonpressed(rating: int) }
this page apple's documentation covers issue.
objective-c swift delegates
No comments:
Post a Comment