Assigning a swift closure (block equivalent) to an existing objective-c block being accessed using a bridge
问题 I am using Swift and was wondering if there's a way I can assign a closure to an existing objective-c block. fromObjC?.performBlock = {someVar in /*do something*/} It gives me an error "Cannot assign to the result of this expression". 回答1: All pointers to objects in objective-C must be Optional in swift because a pointer can be nil. If you know that the variable will never actually be nil, you should use Implicitly Unwrapped Optionals ( TypeName! ) so that you don't have to unwrap it. So void