I can't able to return a custom array of objects from a function in swift. I am always getting [(custon object)] is not convertable to '()' error message. I think i'm violating some swift protocol. Below is my code. Please let me know which i'm violating.
import Foundation
class DataSet {
var settings:Settings!
var service:PostService!
var currentBrand:Brand!
init(){
self.settings = Settings()
self.service = PostService()
}
func loadComments(id:Int) -> [CommentsList]{
service.apiCallToGet(settings.getComments(id), {
(response) in
var commentsList = [CommentsList]()
if let data = response["data"] as? NSDictionary {
if let comments = data["comments"] as? NSArray{
for item in comments {
if let comment = item as? NSDictionary{
var rating = comment["rating"]! as Int
var name = comment["device"]!["username"]! as NSString
var text = comment["text"]! as NSString
var Obj_comment = CommentsList(rating: rating, name: name, text: text)
commentsList.append(Obj_comment)
}
}
}
}
return commentsList //This line shows error as : "[(CommentsList)] is not convertable to '()'"
})
}
}