How to make a class conform to a protocol in Swift?
objective-c, swift
Solution
Type 'CellDatasDataSource' does not conform to protocol 'NSObjectProtocol'
You have to make your class inherit from `NSObject` to conform to the `NSObjectProtocol`. Vanilla Swift classes do not. But many parts of `UIKit` expect `NSObject`s.
class CustomDataSource : NSObject, UITableViewDataSource {
}
But this:
Type 'CellDatasDataSource' does not conform to protocol 'UITableViewDataSource'
Is expected. You will get the error until your class implements all required methods of the protocol.
So get coding :)
Problem
in Objective-C: ``` @interface CustomDataSource : NSObject <UITableViewDataSource> @end ``` in Swift: ``` class CustomDataSource : UITableViewDataSource { } ``` However, an error message will appear: - Type 'CellDatasDataSource' does not conform to protocol 'NSObjectProtocol' - Type 'CellDatasDataSource' does not conform to protocol 'UITableViewDataSource' What should be the correct way ?