Coding on ipad

I would appreciate knowing the limitations the iPad Swift Playgrounds app imposes. For example I was surprised to find that I got a runtime error when I tried to create more than five sub views. Playing with UILabels to present a form is very limiting!


This is the code I used:


import UIKit

import PlaygroundSupport


class MyViewController : UIViewController {

let square50 = CGSize(width: 50, height: 50)

override func viewDidLoad() {

var myFrame = CGRect(origin: .zero, size: square50)

for index in 0...4 {

view.addSubview(UIView(frame: myFrame)) // fails at 6th!

(view.subviews[index] as! UIView).backgroundColor = .red

myFrame.origin.y += 80

}

}

}

PlaygroundPage.current.liveView = MyViewController()

Accepted Reply

In reply to my own question! This code runs fine under XCode on my iMac. The problem rests with the Swift Playgrounds app and is therefore a BUG in the Playgrounds app. Interesting it wasn't spotted by anyone (other than me).

Replies

In reply to my own question! This code runs fine under XCode on my iMac. The problem rests with the Swift Playgrounds app and is therefore a BUG in the Playgrounds app. Interesting it wasn't spotted by anyone (other than me).

>is therefore a BUG in the Playgrounds app


Be sure to file one via the link below, adding your report # to your thread for reference, thanks.