Education

RSS for tag

Teach students of all ages to code in Swift using a variety of resources in your curriculum.

Posts under Education tag

11 Posts

Post

Replies

Boosts

Views

Activity

Swift Playground preview issues
I am a high school teacher from China, currently teaching programming courses at my school. Several issues are preventing the course from being completed on schedule. As shown in the image, there are two problems: The preview issue has existed since updating to the latest software and system version; I don't know how to resolve it. After renaming a Swift file, this window keeps popping up, even after closing it. This problem didn't exist last year. How can I fix this? Thank you for your reply! 我是一名来自中国的高中教师,目前在学校开设编程课程,目前有几个问题导致课程无法如期完成。如图所示,存在两个问题: 一、自从更新了最新版本的软件和系统后,预览问题就存在,不知该如何处理 二、swift文件重命名后,一直跳出来这个窗口,关掉以后还是跳出来 去年的时候还没有存在这样的问题,请问我该如何处理,感谢您的回复!
2
0
52
17h
Beginner Question - Local SPM Folder Structure
Hi there, I am working on an iOS mobile app, with a MVVM architecture and created an SPM folders for my DesignSystem, CoreKit, UnityBridge, and VoicePipeline. I added the packages locally, and dragged them into the project. Is working this way recommended? Or not? Should all the SPM folders I listed above be used this way, or should only some? New to this, unsure what is best. I do plan on sharing my code with other devs to work on. I thought this made sense, but if i did it the other way I was unsure how I would share the packages what is a best practice. Thanks so much!
1
0
100
Jul ’25
How to detect if an iPad is configured as a Shared iPad (Apple School Manager)?
I'm working on an iOS/iPadOS app and need to determine programmatically whether the device is a Shared iPad as configured through Apple School Manager (ASM). Shared iPads allow multiple users to sign in with Managed Apple IDs and are typically used in educational environments. I want to identify this configuration at runtime within my app. I’ve looked into UIDevice, NSProcessInfo, and MDM-related APIs but haven't found a reliable way to detect whether the current device is a Shared iPad. Is there an API or method to check if the current iPad is configured as a Shared iPad (via ASM)? Any guidance or code examples would be appreciated.
0
0
46
Jun ’25
New to Apple Developer Forums — Guidance Appreciated
Hi everyone 👋, I’m new to the Apple Developer Forums and just getting started with building apps for iOS/macOS. I’ve explored the documentation but wanted to introduce myself and ask for some advice from experienced developers. Currently working on: An iOS app using SwiftUI Learning more about integrating Sign in with Apple Exploring best practices for App Store submission Here’s what I’d like to know: What is the recommended approach to saving minimal app state before termination? Are there SwiftUI lifecycle metho18336114753ds or SceneDelegate hooks I should be aware of? Is UserDefaults the best tool for small state preservation in this context? Would love to hear from anyone who’s implemented sim18336114753ilar behavior — even a high-level suggestion would help. Thanks! Harjeet Singh
1
0
154
Jun ’25
Discussion on Location Services and Green light (Will someone deaf or blind ever know when their location was last on?)
Haptic or Sound queue to allow for the accessibility of the blind (sound) and deaf population (haptic) for even knowing when location services and the camera were last used? Also, the grey notification rather than the purple notification for location services should appear for the full 24 hours after an application has used the app, if the correct description is within the "copy" of Settings The green light lets them know that the application has changed to the camera and fade out orange light both could even have subtle simply click sounds, like a shutter, big haptic, softer sound, but editable in Settings, of course
2
1
191
May ’25
Crash when Mutating Array of Tuples with String Property from Multiple Threads
Hi Apple Developer Community, I'm facing a crash when updating an array of tuples from both a background thread and the main thread simultaneously. Here's a simplified version of the code in a macOS app using AppKit: class ViewController: NSViewController { var mainthreadButton = NSButton(title: "test", target: self, action: nil) var numbers = Array(repeating: (dim: Int, key: String)(0, "default"), count: 1000) override func viewDidLoad() { super.viewDidLoad() view.addSubview(mainthreadButton) mainthreadButton.translatesAutoresizingMaskIntoConstraints = false mainthreadButton.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true mainthreadButton.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true mainthreadButton.widthAnchor.constraint(equalToConstant: 100).isActive = true mainthreadButton.heightAnchor.constraint(equalToConstant: 100).isActive = true mainthreadButton.target = self mainthreadButton.action = #selector(arraytest(_:)) } @objc func arraytest(_ sender: NSButton) { print("array update started") // Background update DispatchQueue.global().async { for i in 0..<1000 { self.numbers[i].dim = i } } // Main thread update var sum = 0 for i in 0..<1000 { numbers[i].dim = i + 1 sum += numbers[i].dim print("test \(sum)") } mainthreadButton.title = "test = \(sum)" } } This results in a crash with the following message: malloc: double free for ptr 0x136040c00 malloc: *** set a breakpoint in malloc_error_break to debug What's interesting: This crash only happens when the tuple contains a String ((dim: Int, key: String)) If I change the tuple type to use two Int values ((dim: Int, key: Int)), the crash does not occur My Questions: Why does mutating an array of tuples containing a String crash when accessed from multiple threads? Why is the crash avoided when the tuple contains only primitive types like Int? Is there an underlying memory management issue with value types containing reference types like String? Any explanation about this behavior and best practices for thread-safe mutation of such arrays would be much appreciated. Thanks in advance!
1
0
113
Apr ’25