Posts

Post not yet marked as solved
1 Replies
117 Views
Using: selectedContacts = contacts.filter ({ $0.birthday?.year != nil }) Code compiles but contact still shows. How to select the correct data element from the contacts birthday when it doesn’t contain a year? func contactPicker(_ picker: CNContactPickerViewController, didSelect contacts: [CNContact]) { //selectedContacts = contacts.filter ({ $0.birthday?.value(for: .year) != nil }) selectedContacts = contacts.filter ({ $0.birthday?.year != nil }) //value(for: .year) != nil })
Posted Last updated
.
Post not yet marked as solved
0 Replies
248 Views
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
Posted Last updated
.