0

在objective-c中我们做

@property (strong, nonatomic) void(^Name)(id input, id selectedListItem);

然后我们设置属性

if (self.Name) {
    self.Name(self,nil);
}

访问它视图控制器

[classObject setName:^(id input, id selectedListItem)
// do something with the input and selectedListItem
];

我们如何在 swift3 中做到这一点。

4

1 回答 1

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)
}
于 2017-06-16T13:06:03.590 回答