Last active
August 29, 2015 14:12
-
-
Save ChristianKienle/22bfa174c390e551d810 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
class QueryResult {} // if I make this class public then the compiler says that generate has to be declared public. | |
// If I make generate public I get a different error... | |
// But QueryResult is a class which has to be public... it is part of my public API... | |
public class Row {} | |
class QueryResultGenerator : GeneratorType { | |
typealias Element = Row | |
func next() -> Element? { | |
return nil | |
} | |
} | |
extension QueryResult : SequenceType { | |
typealias GeneratorType = QueryResultGenerator | |
func generate() -> GeneratorType { | |
return QueryResultGenerator() | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks man!
Your code works.
To answer your question:
I would like
QueryResult
to be a public class and I would like to be able to use it in a for loop like this:I am only able to do this if I make the generator public. You mentioned that:
QueryResultGenerator does not have to be private so all is good. Thanks!