Swift 3
import UIKitclass modelDemo: NSObject { var name : String = "" var emailId : String = "" }
创建一个对象然后调佣相应的属性
let modelVar : [modelDemo] = [] // after inserting values in Model print("first object is \(modelvar[0].name)")
Obect-C
@interface ModelDemo: NSObject @property (noatomic, copy) NSString* name; @property (noatomic, copy) NSString* emailId; @end@ implementation ModelDemo @end
执行
ModelDemo* model = [ModelDemo new]; model.name = "Hello" NSArray<ModelDemo*> *array = @[model]; NSLog(@"Name: %@",array[0].name);