Up the mix with Beta 6 #swiftlang

New in Beta 6

I talked about try? in a separate post because it really deserves a longer discussion than quick bullet points.

Completion. Context-sensitive Xcode completion for inferred dot syntax, e.g. MyEnum.Item vs .Item, when the type is clear to the compiler. neat.

Screen Shot 2015-08-24 at 5.41.17 PM

Static Computed Properties in Protocol Extensions. Yay. You can, I believe, also use required protocol members in computing those properties.

Screen Shot 2015-08-24 at 5.42.53 PM

Non-Terminal Variadics. They can appear anywhere in the parameter list, enabling you to most importantly combine variadics with trailing closures.

Screen Shot 2015-08-24 at 5.47.07 PM

Collection Clarity. Non-ObjC types cannot be stored within ObjC-marked properties, e.g. an Array of swift-specific enumerations. Collections containing types that are not Objective-C compatible are no longer considered Objective-C compatible types themselves. For example, previously Array<SwiftClassType> was permitted as the type of a property marked @objc. This is no longer the case. (19787270)

Block imports are now typealiases for Swift-style closures. I’ll just quote Apple: C typedefs of block types are now imported as typealiases for Swift closures. The primary result of this is that typedefs for blocks with a parameter of type BOOL are now imported as closures with a parameter of type Bool (rather than ObjCBool as in the previous beta). This matches the behavior of block parameters to imported Objective-C methods. (22013912)

Type Aliases now get an aka annotation in error messages. So you can see what they alias to for better clarity.

Screen Shot 2015-08-24 at 5.48.35 PM

Print and Debug Print on Steroids. They’re now variadic and you can add a String separator. (I wish they had called it separator and not string because better Update: they did.).  Quick separate post on this. It’s really cool stuff.

public func print(items: Any..., separator: String = default, terminator: String = default)
public func print<Target : OutputStreamType>(items: Any..., separator: String = default, terminator: String = default, inout toStream output: Target)

Screen Shot 2015-08-24 at 5.53.29 PM
RIP appendNewline.

RIP extend(). Long live appendContentsOf(). Same bat behavior, new bat name. Time to go back and fix all my code. *shakes fist*.

All collections are SliceableGinsu!

Most closure ops are rethrows-able. So you can now throw out of maps and filter, and you can try? and &&/||/?? together.

Screen Shot 2015-08-24 at 5.58.44 PM

Screen Shot 2015-08-24 at 5.58.52 PM

5 Comments

  • As far as the completion – just tried it with NSJSONSerialization.JSONObjectWithData(data!, options: .AllowFragments) – no completion for .AllowFragments …

    • Worked for me: http://imgur.com/5kVq6Wy

      • Hm. Yeah. does work in a playground, but doesn’t work in existing file. Will keep playing around (and yeah, I did clean the project)

        • Yep. Looks like if it’s in a closure, it doesn’t work – for me at least:

          let task = session.dataTaskWithRequest(request) {
          data, response, error in

          let d = NSData()
          let j = NSJSONSerialization.JSONObjectWithData(data!, options: .AllowFragments)
          }

          By “design”? Or the closure confuses the autocomplete…

  • Of course… my bigger issue is:

    Xcode does not support two-factor authentication. Developers should continue to authenticate with username and password. (19581582)

    Sorry, not turning off my two-factor auth for you, Xcode… (worked fine in beta 5 and in 6.4)