teodorpatras / Jukebox

Player for streaming local and remote audio files. Written in Swift.
MIT License
551 stars 122 forks source link

How to use init in obj-c? #48

Open bobongski opened 7 years ago

bobongski commented 7 years ago

How can I use this on obj-c? I can't init

RajChanchal commented 7 years ago

@bobongski Which object do you want to 'init'? If it is Jukebox, you could use it somewhat following way to initialize:

JukeBox *player = [[JukeBox alloc]init.........

cesnell commented 7 years ago

@RajChanchal, have you tried this? I'm having the same issue. "'init' is unavailable" is the error message.

RajChanchal commented 7 years ago

@cesnell , you are right pal. After trying the lib in Objective-C, I got to know the initialiser is unavailable. And when I tried finding the reason, I came to know to following conclusion: If you add @objc prior to JukeboxDelegate declaration in Jukebox.swift class, the initialiser initWithItems will work in Objective-C. So, the declaration will be like: @objc public protocol JukeboxDelegate: class

To read more about Interoperability between swift and Objective-C, Go here.

cesnell commented 7 years ago

@RajChanchal, thanks!