Here's a link to a Swift tutorial.
I read the protocol section,i know if protocol is marked with the @objc:
@objc protocol CounterDataSource {
optional func incrementForCount(count: Int) -> Int
optional var fixedIncrement: Int { get }
}
this mean this protocol in order to specify optional requirements and can be adopted only by classes
but tutorial didn't say why the class need to marked with the @objc too??
@objc class Counter {
var count = 0
var dataSource: CounterDataSource?
func increment() {
if let amount = dataSource?.incrementForCount?(count) {
count += amount
} else if let amount = dataSource?.fixedIncrement? {
count += amount
}
}
}
if i remove @objc from class , compiler didn't show error message too
so what different between add @objc to class or not?