Panda Pig • Patty original or translated works. Welcome reprint, Reprint please indicate the source.
If you feel that the writing is not good please more advice, if you feel good please support a lot of praise. Thank you! Hopy;)
You have recently seen one of the following code snippets in COCOS2D programming for Swift:
GameMode:class{ varuserInterface:CCNode! {get} func gameplay(mainScene:MainScene,droppedFallingObject:FallingObject) func gameplay(mainScene:MainScene,caughtFallingObject:FallingObject) func gameplayStep(mainScene:MainScene,delta:CCTime)->GameOver}
Notice that the name of the protocol is followed directly by a class keyword, which is the meaning of God horse?
Read the Swift Programming manual to learn that the class keyword in the protocol is used to restrict the protocol from being applied to classes only, as the exact words say:
toclass types (andnotorbytheclassfirstin a protocol’s inheritance listbefore any inherited protocols”
So if you don't care about this limit, you don't have to add the Class keyword, no difference!
The role of the class keyword in Swift in declaring an agreement