Is there a way to make this code correctly function, loading a webpage (works using iPad playgrounds, not MacOS playground)?
import SafariServices
import Foundation
import PlaygroundSupport
import UIKit
import WebKit
scene.clear()
scene.backgroundImage = imageLiteral(resourceName: "add own foto")
let points = scene.circlePoints(radius: 200, count: 100)
var pointIndex = 0
func doSomething(touch: Touch) {
if touch.previousPlaceDistance < 60 { return }
let EmojiIndex = "🤱👨👩👦👨👩👧👦🚆🚙🚴♂️🏊♂️🏌️♂️📱🧸🌳🍏👨🏻🦳👵🏻".componentsByCharacter()
let Karakters = Graphic(text: EmojiIndex.randomItem)
scene.place(Karakters, at: touch.position)
Karakters.scale = 0.5
if pointIndex >= points.count {
pointIndex = 0
}
pointIndex += 1
let position = points[pointIndex % points.count]
Karakters.move(to: position, duration: 1.0)
}
let tool1 = Tool(name: "Tool 1", emojiIcon: "1️⃣")
tool1.onTouchMoved = doSomething(touch:)
scene.tools.append(tool1)
func buttonPressed () {
let test = SFSafariViewController(url: URL(string:"enter_url")!)
test.title = "Open webpage"
PlaygroundPage.current.liveView = UINavigationController(rootViewController: test)
}
}
let button = Button(name: "Open website")
button.onPress = buttonPressed
scene.button = button
Kind regards, David