News.swift
import UIKit
import Foundation
class News:NSObject {
var accountid = "" //用户
var createDate = 0 //创建时间
var createName = "" //创建人名称
var id = "" //新闻的ID
var style = "" //新闻的总分类
var style2 = "" //新闻的二级分类
var title = "" //标题
var txturl = "" //详情地址
var updateName = "" //更新时间
var uploadimgurl = "" //图片地址
///类方法,用于把一个字典数组转换为News数组
static func createNewsArray(arr:[[String:Any]]) -> [News] {
//创建一个可变的News数组
var newsArr:[News] = []
for dic in arr{
let one = News()
// one.setValuesForKeys(dic)
one.title = dic["title"]! as! String
one.txturl = dic["txturl"]! as! String
one.createDate = dic["createDate"] as! Int
one.createName = dic["createName"] as! String
one.uploadimgurl = dic["uploadimgurl"] as! String
newsArr.append(one)
}
return newsArr
}
override func setValue(_ value: Any?, forUndefinedKey key: String) {
print("没有定义的属性\(key),值\(value)")
}
}
网友评论