神刀安全网

iOS Playgrounds Part 5: Editing real code

While stuck at the Dr’s office, with my daughter being attended to, I decided to try editing a Swift 2.2 playground in iOS Playgrounds, to see if I could upgrade it to Swift 3.0.

The tl;dr is that the tools, while not fully baked, are just as amazing as they were in the WWDC demos. With a few (notable) exceptions, editing source code, invoking fixits, etc. are beautifully realized to the point that I was able to perform non-trivial edits while sitting in a waiting room and using an iPad:

iOS Playgrounds Part 5: Editing real code

I was able to fully update this playground page to run and render.

The Good

Built-in fixits are glorious. As in normal Xcode, they update code by inserting missing labels or replacing code:

iOS Playgrounds Part 5: Editing real code

Multiple errors are paged (as you can see with the two dots at the top of the complaint), and there’s amazing cross referencing with related items, such as when a protocol is not properly implemented or partially implemented. You just tap away to the error point for the candidate issue.

Number and color edits are fantastic: I didn’t realize you could use the number tweaker to just “dial” your way up and down numbers by continuing to twirl into the number pad:

iOS Playgrounds Part 5: Editing real code iOS Playgrounds Part 5: Editing real code

Pages I didn’t expect to work did work! Like this one:  It’s really short. Give it a try.  iOS Playgrounds Part 5: Editing real code

The Not So Good

You can’t fixit many errors:

iOS Playgrounds Part 5: Editing real code

But you can select things and start to type and Playgrounds picks up the context for you:

iOS Playgrounds Part 5: Editing real code

The Ugly

Screenshots are for live views, not playground views. And for some reason, I’m having a lot of difficulty today doing screenshots the old way (hold down sleep/wake, then click home). All of these screenshots are from Xcode’s device window instead.

A lot of confusion comes from inappropriate or missing tool tips. Sometimes it leads you down the garden path:

iOS Playgrounds Part 5: Editing real code

iOS Playgrounds Part 5: Editing real code

What was actually needed looks more like this:

iOS Playgrounds Part 5: Editing real code

Trying to edit “advancedBy” to “advanced” by moving the cursor to the end of By and backspacing was simply a no-go. Playgrounds will remove the entire call at once.

You get a lot of problems with 2.2 items needing to be lowercased for 3, or using old CG constructors like CGRectMake not auto-fixing to CGRect(x:y:width:height). Playgrounds just don’t quite get the “fixit” needed for these simple switches.

iOS Playgrounds Part 5: Editing real code

Even when you’re typing things in, Playgrounds doesn’t always offer you the right choices. In this example, all this needed was to lowercase CGAffineTransform to cgAffineTransform. No fixit and no syntax match:

iOS Playgrounds Part 5: Editing real code

The really cool “drag parenthesis pairs into place” shown in the demos don’t seem to work in the app yet. Instead all I could drag was the letter “j”.

iOS Playgrounds Part 5: Editing real code

You can’t look up module definitions in-place.

No access to Sources that I can find so I can fix errors:

iOS Playgrounds Part 5: Editing real code

The live views are distorted:

iOS Playgrounds Part 5: Editing real code

iOS Playgrounds Part 5: Editing real code

But other than that, wow, what a cool tool. I’m really enjoying it a lot.

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » iOS Playgrounds Part 5: Editing real code

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址