Swift Playgrounds offers a smart, programmer-centric keyboard. Symbols, numbers, and common programming punctuation are included on the main keyboard.
To access an alternate key, tap and then either drag down for single item keys, like qwerty’s numbers, or down-and-left / down-and-right for two-item keys, like fghj’s brackets and parentheses. Release your finger with the gray replacement key shown. Playgrounds uses smart insertion, so you may sometimes add a single bracket or you may add a bracket pair, depending on context.
Try these steps to add a line that says “let x: [Int] = ”:
- Tap the “let” bubble in the top keyboard accessory view. A template appears that says “let name = value”, with name highlighted.
- Tap x. This replaces “name”.
- Pull down on the “k” key until it turns into a colon and release. Playgrounds adds a colon and a space.
- Pull down-and-right on “h” until it turns into “]”. Release. Playgrounds adds a square-bracket pair (“”) and places the cursor in the middle.
- Tap Int on the accessory view.
- Tap the value placeholder in code.
- Repeat step 4 (Pull down-and-right on “h” until it turns into “]”. Release.) to add an empty array literal.
In addition to this sweet, super-convenient programming style, you can also connect a Bluetooth keyboard (or use your computer with a program like Houda’s Type2Phone), dictate (handy for populating comments), or switch to a standard iPhone numeric keyboard by tapping either of the “.?123” keys. You can even use Swift-supported emojis:
After declaring the dog-cow variable, it appears in contextual completion lists like any other symbol:
Izzy notes: The 12″ iPad doesn’t use it because the larger keyboard has an extra row of numbers/symbols. You can tap + hold or swipe up on the numbers to get the symbols without having to use shift.
@ericasadun Re: "no programmer keyboard". The 12" iPad doesn't use it because the larger keyboard has an extra row of numbers/symbols
— Izzy (@frozendevil) June 24, 2016
I agree. After my snarky comment on your last – admittedly obscure and even nitpick post – I need to compliment you on what the playground keyboard is the start of. Good post.
For some reason I do not have the programmer-centric keyboard. Any spesial way to enable programer-centric keyboard.
Can you grab a screenshot for me?