I am trying to convert this script:
@interface EventSource : NSObject
@end
@protocol EventSourceDelegate <NSObject>
- (void)eventSource:(EventSource *)eventSource didFailWithError:(NSError *)error;
- (void)eventSource:(EventSource *)eventSource didReceiveEvent:(NSString *)event withData:(NSString *)data;
@end
@interface EventSource ()
@property id <EventSourceDelegate> delegate;
- (instancetype)initWithURL:(NSURL *)url delegate:(id <EventSourceDelegate>)delegate;
- (void)disconnect;
@end
...and this is how far I got however I couldn't complete it. I have almost no experience in Objective C. I researched a lot about converting however I couldn't find any good for @interaface EventSource () part and @property id but I am stuck here:
import UIKit
class EventSource: NSObject {
}
//@obj
protocol EventSourceDelegate {
func eventSource(eventSource: EventSource, didFailWithError: NSError?)
func eventSource(eventSource: EventSource, didReceiveEvent: NSString,
event withData: NSString, data: NSString)
}
didReceiveEventseems to have lots of extraneous stuff in it. It should befunc eventSource(eventSource: EventSource, didReceiveEvent: NSString, withData: NSString)(depending, of course, upon which parameters are nullable and which are not).