Swift block 用法

我最近在看kf的源码,想看看大佬是怎么写代码,他妈的看完 真是火的一逼,什么垃圾,有些代码写的跟狗屎一样,要实用不实用,要可读没可读性,整天你妈的就知道装逼,真TM是日了狗了,闲的蛋疼,写片文章吐槽下,你TMD!!!

import Foundation

// 这里标记 Input 与 Output 是要干什么呀 他妈的 看不懂啊
class MNCInPutOutPut {
    
    // 我他妈真是个天才 这样牛逼的东西都被我弄明白了 
    init() {}
    
    // 声明一个block block 还能这么玩 妈的
    private var block: ((Input,Input) -> Output?)?
    // 方法 回调
    func delegate(on target: T, block: ((T,Input,Input) -> Output)?) {

        self.block = { [weak target] (input,input2) in
            guard let target = target else { return nil }
            return block?(target, input, input2)
        }
    }
    
    // 入参的回调
    @discardableResult
    func call(_ input: Input,_ input2: Input) -> Output? {
        return block?(input,input2)
    }
    
    // 这两行代码不比上面的香吗  这帮猪啊 装啥逼 就是个垃圾 
    var callBack: ((_ index: Int?, _ model: Any?) -> Void)?
    func viewCallBack(_ index:Int?, _ model:Any?) {
        if let call = callBack {
            call(index, model)
        }
    }
    
}

你可能感兴趣的:(Swift block 用法)