判断是否为空
if response.result is NSNULL {
}
方法设置默认值
public init(context: MapContext? = nil, shouldIncludeNilValues: Bool = false){
self.context = context //默认值 context 为nill
self.shouldIncludeNilValues = shouldIncludeNilValues // 默认值 shouldIncludeNilValues 为false
}
public init(mappingType: MappingType, JSON: [String: Any], toObject: Bool = false, context: MapContext? = nil, shouldIncludeNilValues: Bool = false) {
}
//调用,toObject 省略了
let map = Map(mappingType: .fromJSON, JSON: json, context: context1, shouldIncludeNilValues: shouldIncludeNilValues)
网友评论