Is there interface in Swift? How to use interface? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Is there interface in Swift? How to use interface?

24th Aug 2016, 4:55 PM
Aung Thuya
Aung Thuya - avatar
3 Answers
+ 2
Yes, but in swift they are called Protocols. Protocols in Swift are very similar to Objc, except you may use them not only on classes, but also on structs and enums. this is an example:- protocol SomeProtocol{var fullName:String{get}// You can require iVarsclass func someTypeMethod()// ...or class methods} Conforming to a protocol is a bit different: class myClass:NSObject,SomeProtocol// Specify protocol(s) after the class type Hope you like my answer
26th Aug 2016, 5:59 PM
Prashant
Prashant - avatar
+ 1
thank you so much. i'll continue learning on it.
26th Aug 2016, 6:02 PM
Aung Thuya
Aung Thuya - avatar
0
Yeah! Swift is fun
27th Aug 2016, 3:25 AM
Prashant
Prashant - avatar