Post

Replies

Boosts

Views

Activity

Where are the asset catalog resources stored at runtime?
When I first load my app, where are the assets for, say, images, located? Is it somewhere where loading them in the UI is never a performance issue and can always be done in the main thread? (e.g. even if there were 100 assets loaded at once) I’m assuming it’s safe to load assets from asset catalog in main thread but I want to double check and also learn more.
2
0
107
Nov ’25
When is the StateObject’s autoclosure actually called?
The signature of the StateObject initializer is init(wrappedValue thunk: @autoclosure @escaping () -> ObjectType). The fact that the autoclosure is marked as escaping intrigues me, because that suggests that it could be called after the init has returned. Why this is interesting is because I have some code where the viewmodel given to the @StateObject depends on an implicitly unwrapped optional type, and I expect the top level initialization of the StateObject to crash because the implicitly unwrapped optional is not ready yet, but to my surprise it did not. My theory is that the autoclosure is being called after the View’s initialization had been called, when the dependency is ready. heres a minimal sample of that. class MyDependency: ObservableObject { @Published var value = "Hello" } class MyViewModel: ObservableObject { let dependency: MyDependency init(dependency: MyDependency = TestApp.dependency) { self.dependency = dependency print("✅ ViewModel initialized with dependency:", dependency.value) } } struct ContentView: View { @StateObject private var viewModel = MyViewModel() // ⚠️ expected crash? var body: some View { Text(viewModel.dependency.value).onAppear { TestApp.dependency = Dependency()// dependency is set here after init has been called } } } @main struct TestApp: App { static var dependency: MyDependency! // not ready yet var body: some Scene { WindowGroup { ContentView() } }```
0
0
134
Oct ’25
Where are the asset catalog resources stored at runtime?
When I first load my app, where are the assets for, say, images, located? Is it somewhere where loading them in the UI is never a performance issue and can always be done in the main thread? (e.g. even if there were 100 assets loaded at once) I’m assuming it’s safe to load assets from asset catalog in main thread but I want to double check and also learn more.
Replies
2
Boosts
0
Views
107
Activity
Nov ’25
When is the StateObject’s autoclosure actually called?
The signature of the StateObject initializer is init(wrappedValue thunk: @autoclosure @escaping () -> ObjectType). The fact that the autoclosure is marked as escaping intrigues me, because that suggests that it could be called after the init has returned. Why this is interesting is because I have some code where the viewmodel given to the @StateObject depends on an implicitly unwrapped optional type, and I expect the top level initialization of the StateObject to crash because the implicitly unwrapped optional is not ready yet, but to my surprise it did not. My theory is that the autoclosure is being called after the View’s initialization had been called, when the dependency is ready. heres a minimal sample of that. class MyDependency: ObservableObject { @Published var value = "Hello" } class MyViewModel: ObservableObject { let dependency: MyDependency init(dependency: MyDependency = TestApp.dependency) { self.dependency = dependency print("✅ ViewModel initialized with dependency:", dependency.value) } } struct ContentView: View { @StateObject private var viewModel = MyViewModel() // ⚠️ expected crash? var body: some View { Text(viewModel.dependency.value).onAppear { TestApp.dependency = Dependency()// dependency is set here after init has been called } } } @main struct TestApp: App { static var dependency: MyDependency! // not ready yet var body: some Scene { WindowGroup { ContentView() } }```
Replies
0
Boosts
0
Views
134
Activity
Oct ’25
Is it possible to remove some frameworks from the iOS SDK to make them smaller?
For example, what if I wanted to remove CoreData from the SDK when I install to reduce the SDK’s size?
Replies
6
Boosts
0
Views
145
Activity
Mar ’25
Do Apple built apps on the iPhone use the Apple File System?
It says that the APFS (Apple File System) is the default file system on iOS, but I just want to confirm that all Apple provided apps such as Photos, Notes, Keynote, Mail, use it also. (hope this question isnt as ****** as it sounds, I guess I’m always a bit uncertain with Apple provided stuff as they have secret privileges)
Replies
1
Boosts
0
Views
167
Activity
Mar ’25