错误提示:Initializer for conditional binding must have Optional type, not 'String'
- (void)getHTML:(callBack)block;
self.getHTML 是objc方法 返回的是带参数的block
typedefvoid(^callBack)(NSString*html);
参数是nsstting类型,自动被转换为了string?类型,解包时需要用标准解包写法,先规定解包结果类型,再使用强制解包,否则会出现result类型转换错乱
self.getHTML{ (result)in
//debugPrint(result)
letres :String= result!
self.html=self.getFullHtml(content: res)
self.callbackCellUpdate?()
self.navigationController?.popViewController(animated:true)
}
也可以使用这种写法: result?.utf8
网友评论