0
請參閱下面的代碼我遇到問題。我已經添加了大部分的功能,即使我只是得到了第3行中的錯誤。只是爲了更好地理解我正在嘗試做的事情。遷移後的Contentful SDK代碼問題
func getTopArticles(_ vc: ArticleListViewController, subCatId: String) {
var articleDict = [String: Article]()
Constants.CLIENT.fetchEntries(["content_type":Constants.CONTENT_TYPE_ARTICLE,
"fields.top10Listing.sys.id":subCatId, "order":Constants.SORT_CREATED_AT_DESCENDING]) { //Getting error here
switch $0 {
case let .success(articleResult):
if articleResult.items.isEmpty {
vc.noTopArticlePresent()
}
else{
for articleEntry in articleResult.items {
let article = Article (entry:articleEntry)
vc.art.append(article)
// store into search cache
Constants.ARTICLE_CACHE.fetch(key: "articles").onSuccess({ (result) in
if let dictValue = result as? [String:Article]
{
articleDict = dictValue
articleDict[article.articleId] = article
}
Constants.ARTICLE_CACHE.set(value: articleDict, key: "articles")
}).onFailure({ (error) in
Constants.ARTICLE_CACHE.set(value: articleDict, key: "articles")
})
}
Constants.CACHE.set(value: NSKeyedArchiver.archivedData(withRootObject: vc.art), key: subCatId)
DispatchQueue.main.async {
vc.dothis()
}
}
}
}
得到錯誤在第3行下面
參數標籤看到錯誤「(__:,_ :)」不匹配任何可用的重載