- www.haiku-os.org / www.mobileinteraction.se
- @konrad1977
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
| enum CustomError : ErrorType { | |
| case ErrorWithMessage(message: String) | |
| } | |
| func loginUserWithName(username: String?) throws -> String { | |
| guard let username = username where username.characters.count != 0 else { | |
| throw CustomError.ErrorWithMessage(message: "No username provided") | |
| } | |
| return "token:" + username |
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
| func greetingsForOptionals(name: String?) { | |
| guard let unwrappedName = name where unwrappedName.characters.count != 0 else { | |
| return | |
| } | |
| print("Greetings \(unwrappedName)") | |
| } | |
| var name: String? = "FooBar" | |
| greetingsForOptionals(name) |
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
| var index = 0 | |
| repeat { | |
| index++ | |
| } while index < 100 |
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
| var daysInMonth: Int = 30 | |
| var currentYear: 2000 | |
| let months: 12 | |
| enum Sex { | |
| case Male | |
| case Female | |
| case Unknown | |
| } |
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
| func getWelcomeMessageToUser(user: String) -> String { | |
| return "Hello " + user | |
| } |
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
| func myFirstFunction() { | |
| let message = "hello world!" | |
| print(message) | |
| } |
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
| void UpdatePersonWithId(int personId) { | |
| Person personToFind = FindPersonWithId(personId); | |
| if (personToFind != null) | |
| SavePerson(personToFind); | |
| } | |
| void FindPersonWithId(int personId) { | |
| Person personToFind = null; | |
| foreach(person in personList) { | |
| if (person.id == personId) { |
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
| void UpdatePersonWithId(int personId) { | |
| Person personToFind = null; | |
| foreach(person in personList) { | |
| if (person.id == personId) { | |
| personToFind = person; | |
| break; | |
| } | |
| } | |
| SavePerson(personToFind); | |
| } |
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
| class TableViewContorllerThatWorks: UITableViewController { | |
| override init(style: UITableViewStyle) { | |
| super.init(style: style) | |
| } | |
| required init(coder aDecoder: NSCoder) { | |
| fatalError("init(coder:) has not been implemented") | |
| } | |
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
| class Factory { | |
| } | |
| extension Factory { | |
| class var SharedInstance: Factory { | |
| struct Static { | |
| static let instance: Factory = Factory() |