objective c - obj-c's class custom initializer doesn't show up in swift -
i knew swift , don't have experience objective-c. here objective-c class want use in swift code websocket.h :
#import <foundation/foundation.h> @class httpmessage; @class gcdasyncsocket; #define websocketdiddienotification @"websocketdiddie" @interface websocket : nsobject { dispatch_queue_t websocketqueue; httpmessage *request; gcdasyncsocket *asyncsocket; nsdata *term; bool isstarted; bool isopen; bool isversion76; id __unsafe_unretained delegate; } + (bool)iswebsocketrequest:(httpmessage *)request; - (id)initwithrequest:(httpmessage *)request socket:(gcdasyncsocket *)socket; @property (/* atomic */ unsafe_unretained) id delegate; @property (nonatomic, readonly) dispatch_queue_t websocketqueue; - (void)start; - (void)stop; - (void)sendmessage:(nsstring *)msg; - (void)senddata:(nsdata *)msg; - (void)didopen; - (void)didreceivemessage:(nsstring *)msg; - (void)didclose; @end @protocol websocketdelegate @optional - (void)websocketdidopen:(websocket *)ws; - (void)websocket:(websocket *)ws didreceivemessage:(nsstring *)msg; - (void)websocketdidclose:(websocket *)ws; @end
and have added above header file xxxx-bridging-header.h this
#import "websocket.h"
but when want try instantiate websocket class can't see initializer in autocompletion :
i think problem lies in fact not importing dependencies:
@class httpmessage; @class gcdasyncsocket;
are unknown swift because neither bridging header or websocket.h
importing/including them. therefore method uses them cannot accessible in swift.
Comments
Post a Comment