Post not yet marked as solved
I have reached to Learn to Code 2, Chapter: Types, Corner of The World puzzle.
however; I have provided a solution and the Playground did not close the puzzle, but the avatar stop moving as it meets the conditions I set!!
I searched the internet and found the solution, I copied the solution, the puzzle closed!!
but my solution was much shorter than the solution!!
I am not sure what is wrong in my code, I have attached my code.
`greenPortal.isActive = false
orangePortal.isActive = false
var numberOfGems = 0
var numberOfSwitchs = 0
func moveAround() {
if isBlockedRight {moveForward()} else {turnRight()
moveForward()
}
if isBlocked {turnLeft()
turnLeft()
}
}
turnRight()
moveForward()
for steps in 1...2 {
moveForward()
turnRight()
moveForward()
if isOnClosedSwitch {toggleSwitch(); numberOfSwitchs = numberOfSwitchs + 1}
turnLeft()
turnLeft()
}
while !isBlocked {
while numberOfSwitchs < 6 {
moveAround()
if isOnGem {collectGem(); numberOfGems = numberOfGems + 1}
if numberOfGems == 6 {greenPortal.isActive = true}
if isOnClosedSwitch {toggleSwitch(); numberOfSwitchs = numberOfSwitchs + 1}
if isOnOpenSwitch {greenPortal.isActive = false}
}
}
Hello,
I'm trying to make my own app (private) for my home automation which I've made with esp32 microcontroller.
at this moment I've developed a small testing app in Xcode with just 1 slider button: LED ON/OFF.
I've connected the Led to the esp32.
my esp32 creates a web server with the slider button.
in Xcode is program the IP url to acces the web server and then control the led with my custom app.
QUESTION:
Is there a way I can leave out the web server?
Custom app controls directly I/O off esp32?
when I use the app now, it's kinda slow in reactiontime cause It needs to contact the webserver first.
Post not yet marked as solved
UIVisualEffectContentView.contentView.addSubview appears to be actually trying to add the sub view to the parent UIVisualEffectView in Swift Playgrounds. Code that works fine in an actual iOS app causes Swift Playgrounds to produce error: "Do not add subviews directly to the visual effect view itself, instead add them to the -contentView." Except that is exactly what the code is doing "blur.contentView.addSubview(vib)" So the internal implementation in Swift Playgrounds must be doing something wrong. Again the same code works fine in an iOS app.
Post not yet marked as solved
I just installed Swift Playgrounds on newly installed Monterey. There is not much else installed (ie, no Xcode). The initial screens of Playgrounds seem to render properly (ie against the blue background). Then when the lesson begins the instruction and coding window appear fine, but the right panel is just a blue background with either nothing at all or a tiny little box at the top of screen that says 0/1. It seems like the animations are not rendering. I have tried to reinstall but same issues. This seems to occur in all the lessons. I have no idea where to even begin troubleshooting this and I have searched the internet and nothing similar seems to be mentioned. Suggestions?
Hi. I am currently implementing inter-application communication using DistributedNotificationCenter within swift 5.6 and Xcode Version 13.3.1 (13E500a).
So I typed the code below into Playground, but I get the error "Cannot find 'DistributedNotificationCenter' in scope".
import Foundation
let dnc = DistributedNotificationCenter.default()
As this document says, DistributedNotificationCenter is included in the Fundation, so I should be able to use it if I write it that way, but I can't.
I would appreciate it if you could tell me how I can use DistributedNotificationCenter
Thanks,
So the name on my team name, dev account name and dev forum name is my deadname and I obviously want it gone. I know that I cannot change them normally (which is ridiculous), but is changing any of them an option when migrating from a free dev account to a paid one?
So my questions are:
1- I do not have a paid dev account yet. When I get one, will I be able to change one of those names? (or add new ones)
2- Will any of those names that are currently set be publicly seen if I publish an app to the App Store?
3- If I have to create a new account, it is possible to use an account on XCode different from the one on my mac and to use an account on Swift Playgrounds different from the one on my iPad, right?
Not really willing to test it myself since if this is not possible I won't pay for this on this account, but will have to create another one.
Thanks in advance,
Luana
I
I am doing a swift curriculum. I need to find an assistant editor how it is shown on the page. But I can't find it. Please let me know if you know where is it. The first screenshot is how it should look and the second one is what I have now
Post not yet marked as solved
Since this year they want a .swiftpm file and it can't run on Playgrounds on mac, my submission has to be Swift Playground 4.0.2 for iPad?
If I choose Xcode for Mac, will they run on debug or will they try to open it on Playgrounds (and get an error)
Post not yet marked as solved
All the files in my app's package add upto 7 MB. But my swiftpm package has a size of 40.7 MB! i dont get how its possible. could you please offer a workaround? Thank you!
all my deliverables are done so this sucks :/
Post not yet marked as solved
Hello guys! Does anyone know how to export an Xcode app project in na Swift Playgrounds' playground?
Post not yet marked as solved
Hi there! I have a public structure and I called it in my ContentView, but I can't understand where to punt the var/let. I try to put them before "var body: some view" but it gives me these errors.
Post not yet marked as solved
I've been developing a Playground that works just fine on the Swift Playground app on Mac. I used the Swift Playground Author Template from Apple.
Is it a Swift Playground or an Xcode Playground? I'm a bit confused given that I tested my Swift Playground on Mac, not on iPad.
Post not yet marked as solved
Hello world! I was creating a playground with Swift Playgrounds, and I created a .swift files and should connect these files to ContentView(), but when I write that file name on ContentView() it tells me "Cannot find ... in scope".
Does anyone know why this error and how to fix it?
Thanks in advance from heart.
Post not yet marked as solved
İ am getting "Failed to produce a diagnostic for expression; please file a bug report" error.
import SwiftUI
struct ContentView: View {
let lifeformanalyzer = Lifeformanalyzer()
@State var text = ""
@State var title = "Merhaba insan!"
var body: some View { ————> error is here
VStack {
Image(systemName: "face.smiling.fill")
.imageScale(.large)
.foregroundColor(.accentColor)
.padding(.top, 50)
Text(title)
.font(.largeTitle)
Spacer()
TextField("Birşey yazın", text: $text)
.multilineTextAlignment(.center)
.frame(width: 300)
Spacer()
Button("Gönder") {
submit()
}
Spacer()
}
.padding()
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(Color(red: 0.024, green: 0.392, blue: 0.549))
.ignoresSafeArea()
func submit() {
}
var title = "Merhaba \(lifeformanalyzer.processLifeform(text: text))!"
}
}
The other swift file Lifeformanalyzer:
class Lifeformanalyzer {
func processLifeform(text: String) -> String{
text.lowercased().contains("vak")
? "ördek" : "insan"
}
}
Is there a way to add custom font for Swift Playground App, since I can't add a Info.plist file?
I've encountered an issue where a swift playground app (when run in its own window) becomes unresponsive after approximately 3 minutes. The window goes dim and the playground ceases to respond. The HUD automatically comes down to suggest restarting the code. No error in my code is reported, and I seem to only ever encounter this issue when running from Swift Playgrounds on iPad (not an issue on Xcode).
I know there is a 3 minute limit anyway for the Swift Student Challenge, but is anyone else experiencing the same issue? if not, any thoughts on possible causes of this?
My playground app runs perfectly fine when I compile it on Xcode on my Mac to run it on my iPad, but for some reason it won't run at all when I try running it directly on Swift Playgrounds (the file opens and it doesn't give me any errors, but it won't compile). How might I be able to fix this?
My app is a .swiftpm file and I'm using Swift Playgrounds 4.0.2 on iPadOS 15.4.1.
Any help would be greatly appreciated!
Hello there!
I would like to set an image as the background of my project in SwiftUI, but I have no idea how it is done.
Could anyone help me to figure out this?
I am using Swift Playgrounds and SwiftUI framework.
I'm constructing a Swift Playground with UIKit that contains an SKScene. After creating the code I'm planning to use within an Xcode project, I tried to adapt it into my Playground.
I encountered an issue while running the Playground - when a new SKSpriteNode is added to the Scene, the new and existing nodes jitter, freeze, and lag for a split-second, the FPS counter drops to around 49fps, then returns to smooth 60fps. No errors or warnings are spat, and the console is completely empty.
The scene in the project didn't have this issue, and I can't recreate it on another project - even when I directly copy-paste the code from the Playground to the project.
I've seen other posts with this question - and made a few myself elsewhere - and there's been no responses. I desperately need help for this as nothing I've tried is working and the deadline is in a few days!
Thanks!
The code that is in effect for this SKScene is below.
class SimulatorController: UIViewController {
override func loadView() {
let view = SKView()
let scene = GameScene(size: view.bounds.size)
view.showsFPS = true
view.showsNodeCount = true
view.ignoresSiblingOrder = true
scene.scaleMode = .resizeFill
view.presentScene(scene)
self.view = view
}
}
class GameScene: SKScene {
override func didMove(to view: SKView) {
run(SKAction.repeatForever(SKAction.sequence([
SKAction.run(addNeutron),
SKAction.wait(forDuration: 1)
])
))
}
func random() -> CGFloat {
return CGFloat(Float(arc4random()) / 0xFFFFFFFF)
}
func random(min: CGFloat, max: CGFloat) -> CGFloat {
return random() * (max - min) + min
}
func addNeutron() {
let neutron = SKSpriteNode(imageNamed: "neutron.heic")
neutron.size = CGSize(width: 20, height: 20)
neutron.physicsBody = SKPhysicsBody(rectangleOf: neutron.size)
neutron.physicsBody?.isDynamic = true
let actualX = random(min: 0, max: size.width)
let actualY = random(min: 0, max: size.height)
neutron.position = CGPoint(x: actualX, y: actualY)
addChild(neutron)
let actualDuration = random(min: CGFloat(2.0), max: CGFloat(4.0))
let actualX2 = random(min: 0, max: size.width)
let actualY2 = random(min: 0, max: size.height)
let actionMove = SKAction.move(to: CGPoint(x: actualX2, y: actualY2), duration: TimeInterval(actualDuration))
let actionMoveDone = SKAction.removeFromParent()
neutron.run(SKAction.sequence([actionMove, actionMoveDone]))
}
}
Post not yet marked as solved
In the Swift Playgrounds app on my iPad, there is an option to create an app, a playground, or an Xcode Playground. Which one are we supposed to use in order to be eligible for the challenge?