我制作了NSObject
来解析collectionView
的值。它将构建失败,因为它在重新键入时显示错误。我认为我有编写代码的问题。但我不知道我的错误在哪里,请尽力帮助我。
import UIKit
import Foundation
class AppCategory: NSObject {
var tShirtImageOb: String?
var tShirtLabelOb: String?
var tShirtPrizeOb: NSNumber?
static func sampleAppCategories() -> [AppCategory] {
var bestNewAppsCategoryArray = [AppCategory]()
let bestNewAppsCategory = AppCategory()
bestNewAppsCategory.tShirtImageOb = "tShirt"
bestNewAppsCategory.tShirtLabelOb = "Best New Apps"
bestNewAppsCategory.tShirtPrizeOb = NSNumber(value: 599.0 as Float)
bestNewAppsCategoryArray.append(bestNewAppsCategory)
var bestNewGamesCategoryArray = [AppCategory]()
let bestNewGamesCategory = AppCategory()
bestNewGamesCategory.tShirtImageOb = "tShirt"
bestNewGamesCategory.tShirtLabelOb = "Best New Apps"
bestNewGamesCategory.tShirtPrizeOb = NSNumber(value: 599.0 as Float)
bestNewGamesCategoryArray.append(bestNewGamesCategory)
// show the error in down line
return [bestNewAppsCategoryArray, bestNewGamesCategoryArray]
}
}
答案 0 :(得分:1)
如果您想要返回包含所有新游戏和新应用类别的AppCategory
对象数组,请将它们一起添加到返回行中。
所以改变这一行
return [bestNewAppsCategoryArray, bestNewGamesCategoryArray]
向
return bestNewAppsCategoryArray + bestNewGamesCategoryArray