swift-box:Swift的盒子实现

Swift框实现Swift的实现。当某些值可能包含错误时,这很有用,例如从API获取某些模型时。安装添加pod 'SwiftBox'到您的PodFile。用法您可以使用创建一个Box let fullBox = Box < String> ( " foo " ) let failureBox = Box < String> ( NSError ( domain : " foo " , code : 2 , userInfo : nil )) // will be failure let emptyBox = Box < String> . Empty然后您可以使用您的盒子: if box. isFull () { tlet myString = box >! // == box.value! } if box. isFailure () {
zip 文件大小:7.39KB