Created
March 10, 2016 22:00
-
-
Save dcunited001/05549bccc146924af537 to your computer and use it in GitHub Desktop.
Swift protocol questions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import Fuzi | |
import Swinject | |
// option one | |
// - fails because of "Self or associated type errors" | |
public protocol ParserNode { | |
typealias GenerateType | |
// parses xml nodes onto attributes defined on the ParserNode | |
func parseXML(nodes: Container, elem: XMLElement) | |
func generate(containers: [String: Container], options: [String: Any]) -> MDLType | |
// i'm getting errors here | |
func copy() -> ParserNode | |
} | |
// option two | |
// - it works, but I'm hesitant because of Generic-only constraints on ParserNode protocol | |
public protocol ParserNode2 { | |
typealias NodeType | |
typealias GenerateType | |
func parseXML(nodes: Container, elem: XMLElement) | |
func generate(containers: [String: Container], options: [String: Any]) -> MDLType | |
func copy() -> NodeType | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment