Trouble reproducing a bug? Run this checklist to make sure you're reproducing user's environment as closely as possible:
Device
- iOS version?
- iPad/iPhone?
- CPU architecture?
- Screen size? Orientation? Slide-over/Split View?
iOS settings
| post_install do |installer| | |
| installer.pods_project.build_configurations.each do |configuration| | |
| configuration.build_settings['SWIFT_VERSION'] = '2.3' | |
| configuration.build_settings['PROVISIONING_PROFILE_SPECIFIER'] = 'WT398A4BZ6/' # replace with your Team ID | |
| end | |
| end |
| IO.write 'funcs.txt', (Dir["**/*.swift"] - Dir["{Libraries,Pods}/**/*.swift"]).flat_map { |f| IO.read(f).lines.select { |l| l.include? 'func ' }.map { |l| l.strip } }.join("\n") |
| // Dumb (and really slow) | |
| import Foundation | |
| func combinations(height: Int, _ level: Int) -> Int { | |
| if (level == 1) { | |
| return height + 1 | |
| } else { | |
| var sum = 0 | |
| for i in 0...height { |
Trouble reproducing a bug? Run this checklist to make sure you're reproducing user's environment as closely as possible:
Device
iOS settings
| // Option 1: if..elseif + optional unwrapping conditions | |
| private func handleNotificationAction(id: String?, userInfo: [NSObject: AnyObject], responseInfo: [NSObject: AnyObject]?, completion: () -> Void) { | |
| let taskId = userInfo["extra"]?["task_hash"] as? String | |
| let projectId = userInfo["extra"]?["project_hash"] as? String | |
| let comment = responseInfo?["UIUserNotificationActionResponseTypedTextKey"] as? String | |
| if id == "comment", let task = taskId, comment = comment where !comment.isEmpty { | |
| } else if id == "invitation_accept", let project = projectId { |
| class Foo { | |
| subscript(key: String) -> String { | |
| get { a } | |
| set { b } | |
| } | |
| subscript(key: String) -> String { | |
| get { a } | |
| set { b } | |
| } |
| class A { | |
| subscript(key: B) -> C { | |
| get { d } | |
| set { e } | |
| } | |
| } |
| class C { | |
| let alias: Foo -> Void = f // error: Foo not a subtype of C | |
| let alias2 = f // : C -> Foo -> Void | |
| func f(arg: Foo) { | |
| // ... | |
| } | |
| } |
| # this doesn't do what you think it does | |
| if f = foo && b = bar; end | |
| # this works: | |
| if (f = foo) && (b = bar); end | |
| # and this works: | |
| if f = foo and b = bar; end |