Swift. Declaring private functions in internal protocol

前端 未结 2 1480
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-13 02:34

How can I achieve something like this (doesn\'t compile):

internal protocol InternalPrivateMix {
    private func doPrivately()
    internal func doInternaly         


        
2条回答
  •  死守一世寂寞
    2021-01-13 02:59

    You can do this:

    protocol P {
        func int()
    }
    
    extension P {
        func int() {
            print("int()")
            priv()
        }
        private func priv() {
            print("priv()")
        }
    }
    

    Which might serve your purpose - I use it.

提交回复
热议问题