Skip to content

Instantly share code, notes, and snippets.

@paulw11
Created February 9, 2019 07:26
Show Gist options
  • Save paulw11/7a877a412d661f5e6665695bb70e85c2 to your computer and use it in GitHub Desktop.
Save paulw11/7a877a412d661f5e6665695bb70e85c2 to your computer and use it in GitHub Desktop.
protocol Revisionable {
}
class RealType: Revisionable {
}
func setMyRealStuffRevision(entity name: String) -> [(RealType,Int)] {
return setThingRevision(entity: name)
}
func setThingRevision<GenericType:Revisionable>(entity name: String) -> [(GenericType,Int)] {
var resultArray = [(GenericType,Int)]()
// Here name contains the name of a Core Data entity and getArrayFromEntity is
// a local function, extracting an array from the contents of the entity.
for item in getArrayFromEntity(name) as! [GenericType] {
resultArray.append((item, 99))
}
return resultArray
}
func getArrayFromEntity(_ name: String) -> [RealType] {
return [RealType()]
}
let x = setMyRealStuffRevision(entity: "Test")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment