在objective-c中我们做
@property (strong, nonatomic) void(^Name)(id input, id selectedListItem);
然后我们设置属性
if (self.Name) {
self.Name(self,nil);
}
用于访问它的viewcontroller
[classObject setName:^(id input, id selectedListItem)
// do something with the input and selectedListItem
];
我们如何在swift3中完成它。
答案 0 :(得分:0)
@property (strong, nonatomic) void(^Name)(id input, id selectedListItem);
是
var name: ((input: Any, selectedListItem: Any?) -> ())? = nil
设置
obj.name = { (input, selectedListItem) in
// do something with the input and selectedListItem
}
致电是
if let name = obj.name {
name(self, nil)
}