All Questions
Tagged with swift swift-playground
1,074
questions
-2
votes
1
answer
66
views
Escaped Double Quote in Swift breaking JSONDecoder decode
If you open a play ground and paste this code, you'll notice that the decoded object is nil. The JSON object [{"transcript":"A person might say, \"Hello\"."}] passes any ...
-1
votes
1
answer
31
views
longest prefix substring in a string in swift
Check this code on xcode playground
I am trying to get the longest prefix substring from string in swift.
This solution is working but I have a question
the min function is not giving me desired "...
1
vote
1
answer
54
views
NSCFRunLoopSemaphore wait assertion error in NSInternalInconsistencyException
I've tried several ways to attempt to get async working in Playground. I've seen in a place where Task {} in combination with PlaygroundPage.current.finishExecution() may be the way to go:
updated ...
0
votes
1
answer
78
views
Completely illogical Date() values, in Swift
When I try to add a time interval to a given date at the end of some of the months, I get illogical results.
In the following example, when I add 5 hours to an 8:00PM time, in the given date, the ...
2
votes
1
answer
70
views
What is wrong with this API call parsing JSON data?
This is the current SWIFTUI code I have:
import SwiftUI
struct Holidays: Decodable {
var date: String
var localName: String
var name: String
var countryCode: String
}
struct ...
1
vote
0
answers
56
views
Modifying the background of views built with NavigationStack and Lists in SwitfUI
NavigationtStack, combined with Lists and Sections makes building a native UI very easy in SwiftUI. Looking at Apple's own apps there are certain bits of flair which I am looking to achieve in my own ...
-1
votes
1
answer
106
views
how to display loop times in playground [closed]
I want to get the loop times info in playground. But it seems to only display the latest result for a loop on the right side. Do I miss anything? Xcode 15.0.1
import Cocoa
for i in 1...5{
print(&...
0
votes
0
answers
69
views
Core ML model class not getting generated in App Playground Xcode
I am trying to use the SqueezeNet coreML model, but it says that model is not part of any target and to add the model to a target to enable the model class generation. I can not add it to a target ...
0
votes
0
answers
54
views
Is there a way to change images while using a image inside a NavigationLink in SwiftUI?
I'm relatively new to Swift development and I'm encountering an issue with SwiftUI that I haven't been able to solve despite days of research.
I am trying to create a view where an image acts as a ...
1
vote
1
answer
187
views
SwiftUI Image is not showing up in Swift Playground on macOS using Xcode 15
I have a Swift Playground in Xcode 15 that has a file structure as follows:
|-.swiftpm/
|----Resources/
| |----cat.png
| |----plane.png
| |----train.png
|----MyApp.swift
|----ExampleView....
1
vote
3
answers
213
views
Sink.receive() Does Not Get called After Declaring an Initial Value in Combine Swift
Issue:
I am using a Publisher in a code example which I wrote based on the code example here, [https://developer.apple.com/documentation/combine/observableobject][1]. I expect the print statement ...
0
votes
0
answers
54
views
Swift Playground does not find SpriteKit particle file
I'm making a a project that has to use swift playground (.swiftpm);
It uses swiftUI for some elements but the main is on a SpriteKit Scene. My problem is that I want to use a particle and it just can'...
1
vote
0
answers
184
views
Swift Playgrounds: How to add HDRI in a non AR RealityKit project?
I am creating a RealityKit project on Swift Playgrounds in Xcode, but I am using it in a perhaps less common way. I am using RealityKit but without AR, which is possible by an initializer of ARView.
...
1
vote
0
answers
71
views
Swift Playground Bundle can't find Compiled CoreML Model (.mlmodelc)
I have been attempting to debug this for over 10 hours...
I am working on implementing Apple's MobileNetV2 CoreML model into a Swift Playgrounds. I performed the following steps
Compiled CoreML model ...
0
votes
0
answers
27
views
Copy resources to App Bundle in Swift Playground [duplicate]
I am attempting to load a USDZ file into a QuickLook view from within a Swift Playground. This USDZ file is in the root of my playground. Unfortunately, my project needs to be a playground so I can't ...