Swift: #warning equivalent

Does Swift have a #warning equivalent? It’s simply used to show a warning in Xcode’s own GUI I’m also interested in whether there’s a #error equivalent. Apple has said #pragma mark is coming soon, it could possibly be the same with this. 14 Answers 14

Flatten an Array of Arrays in Swift

Is there a counterpart in Swift to flatten in Scala, Xtend, Groovy, Ruby and co? var aofa = [[1,2,3],[4],[5,6,7,8,9]] aofa.flatten() // shall deliver [1,2,3,4,5,6,7,8,9] of course i could use reduce for that but that kinda sucks var flattened = aofa.reduce(Int[]()){ a,i in var b : Int[] = a b.extend(i) return b } 14 Answers 14

Wait until swift for loop with asynchronous network requests finishes executing

I would like a for in loop to send off a bunch of network requests to firebase, then pass the data to a new view controller once the the method finishes executing. Here is my code: var datesArray = [String: AnyObject]() for key in locationsArray { let ref = Firebase(url: “http://myfirebase.com/” + “\(key.0)”) ref.observeSingleEventOfType(.Value, withBlock: … Read more

SwiftUI: How to implement a custom init with @Binding variables

I’m working on a money input screen and need to implement a custom init to set a state variable based on the initialized amount. I thought this would work, but I’m getting a compiler error of: Cannot assign value of type ‘Binding<Double>’ to type ‘Double’ struct AmountView : View { @Binding var amount: Double @State … Read more