
New in Beta 2, you can now drag in and drop colors, images, and files. You don’t see this in the screenshot but if you open the value history pane for the text assignment, it shows the text of that file (my shopping list, for the curious). The text constant is typed as NSURL
. Color is UIColor
, Pic is UIImage
. No question marks for any of them, thankfully.
- Interestingly enough, you can drag the tokens around the playground. So if you accidentally drop a picture on the color line, just drag it down to the image assignment.
- You can also option-drag items to copy them.
- Double-click colors to open a color picker (yay!), images to open the resources folder to select other resources. Double-clicking on URLs doesn’t seem to do anything that I can find.
- You cannot resize the wee placeholders but you can resize their value history panes just as if you had typed any other value.
- You cannot generate swatches from
UIColor
calls (yet), for example UIColor.blueColor()
doesn’t swatchize. I’ve found it easiest to just drag in from outside or copy/drag another swatch and then assign with the color wheel.
- If the wee icon is colored blue, do not type. Click off of it or your next keystroke will replace it. Blue means selection and they can be overwritten. Easily.
Tip for the wise: do not drag a playground into itself. Seriously. Been there. Done that.

In any case, the files are copied into the resources folder. So:
- Don’t copy the same file twice by drag/dropping it. Xcode doesn’t like that.
- Don’t expect edits on the source file to propagate. Once added, refer directly to the resources folder.
- Colors aren’t copied to resources, they’re just value items.
- This is pretty much all you can drop right now. For example, you can’t “copy” URLs from Safari. They come over as pure text and need escaping. Expect the drag and drop vocabulary to expand over time, but right now it’s colors, pics, local file NSURLs.
- As mentioned, don’t drag a playground onto itself.
Other new things
Quite a lot of changes about how Swift reacts to imported enums, unions, NSNumbers, etc. Worth reviewing the release notes if you work with a lot of cross-language code.
The whole “never use a double-quote in a string interpolation” dies in Swift 2.1.
Expressions interpolated in strings may now contain string literals. For example, “My name is \ (attributes[“name”]!)” is now a valid expression. (14050788)
Some performance improvements in the compiler. Items without any dependencies (that is, marked private) won’t trigger recompilation of other files.
Function types are more lenient now. So you can assign, for example, an Any->Int closure to a String->Any variable. I’m still trying to wrap my mind about whether this is a good thing or not.
Conversions between function types are now supported, exhibiting covariance in function result types and contravariance in function parameter types. For example, it is now legal to assign a function of type Any -> Int to a variable of type String -> Any. (19517003)
This next one is the biggest change for me outside of the playgrounds thing. Which is that errors about map closures (_ -> _ sound familiar?) are now “much more usefully diagnosed”. Can’t wait to kick the wheels on this one.