Post

Replies

Boosts

Views

Activity

Reply to I want to develop my first app
In summary, I wonder if the app can be developed as planned with the minimum hardware elements (purchase of insufficient machine or upgrade of system specifications) that go into making the three apps I envisioned. It took time to develop, but it would be sad if it was out of service support just before the goal, or if it violated Apple's policy. In my opinion, 2020 M1 MacBook Air (256 GB, 16 GB RAM) and an M1 iPad Pro 11 inch (8 GB RAM) would not be a super bad choice and it might be enough for developing a few, relatively simple apps. But you will soon feel that 256 GB is not enough and you may need to clean up your Mac very often. Anyway, start now, learning Apple's frameworks and programming languages might take far more time that you expect.
Oct ’21
Reply to Contents of .sheet() are being redrawn after dismiss and not presenting
Is this normal behavior? The ContentView body makes sense to change, but is the sheet's body also supposed to be redrawn when the sheet is not presenting anymore after dismiss? I do not understand what your term redraw means, but if it means body being evaluated, the answer would be: You should not care about that. The property body would be called at any time when the runtime of SwiftUI thinks it is needed, your code should not depend on when or how may times it may be called. It is sort of implementation details of SwiftUI, and may be changed at any time in the future.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’21
Reply to Unexpected non-void return value in void function error in function
What am I doing wrong? When you want to return a value from a closure, the closure must be declared as to return a value. But, the closure type in observeSingleEvent(of:with:) is not declared to return a value. When you want to pass something after some asynchronous operation is finished, one traditional way is using the completion handler pattern. In your case, something like this: func returnusername(completion: @escaping (String?)->Void) { guard let uid = Auth.auth().currentUser?.uid else { completion(nil) return } //guard (Auth.auth().currentUser?.uid) != nil else {return} //<- Duplicate check, is not needed Database.database().reference().child(uid).child("users").child("username").observeSingleEvent(of: .value){ (snapshot) in guard let username = snapshot.value as? String else { completion(nil) return } completion(username) } } You can use it as follows: func someMethod() { returnusername { username in guard let username = username else { return } //Use `username` here... //... } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’21
Reply to XCode 13 - Task not found in scope?
Thanks to Claude31, I could have explored a little more. Instead of import UIKit, import _Concurrency (in addition to import Foundation) will make it. What is odd is we do not need import _Concurrency in app projects. (You should not use import _Concurrency in actual projects, it may be treated as using a private framework.) And one more odd thing is import _Concurrency can be found when I see the generated header for Foundation by Cmd-clicking the line import Foundation.
Oct ’21
Reply to Inconsistency in C double precision comparison
Duplicate post is considered to be a bad manner, you should better care about it. And your question has nothing to do with the WWDC21 session wwdc21-10002, you should use the right tag. And the problem you have experienced, happens because C-double is a binary floating point number type and which cannot represent the value 0.1 precisely. It is the common behavior on all platforms which uses binary floating point, not only on Apple's platform. So, asking it in the Apple's dev forums is not appropriate. You should better find a good site to learn numeric processing.
Topic: Programming Languages SubTopic: Swift Tags:
Oct ’21
Reply to Exception NSException * "[<Calculus_area_and_perimeter.ViewController 0x14c506020> setValue: forUndefinedKey:]: this class is not key value coding-compliant for the key calcArea." 0x0000600002799cb0.
When you get a runtime exception with this message, "[<Calculus_area_and_perimeter.ViewController 0x14c506020> setValue: forUndefinedKey:]: this class is not key value coding-compliant for the key calcArea."  iOS runtime is trying to connect an instance declared on storyboard/xib into the @IBOutlet of ViewController named calcArea. Don't you remember you once connected something to an @IBOutlet and name it calcArea, and then renamed it to something else? Anyway, you may need to remove the wrong connection pointing calcArea, and re-connect it to the right @IBOutlet.
Topic: Programming Languages SubTopic: Swift Tags:
Oct ’21
Reply to How can you pause a SpriteKit scene from SwiftUI, without reinitializing it every time?
You should better include the code as text, which helps involving more readers. In your code, scene is a computed property, so it is evaluated at each time body is evaluated. Generally, you should better avoid creating a computed property which creates a new instance, especially when the identity is important. Please try something like this: class GameScene: SKScene, ObservableObject { //<- private let label = SKLabelNode(text: "Time Elapsed:\n0") private var lastUpdateTime : TimeInterval = 0 override func didMove(to view: SKView) { addChild(label) } override func update(_ currentTime: TimeInterval) { if (self.lastUpdateTime == 0) { self.lastUpdateTime = currentTime } let seconds = Int(currentTime - lastUpdateTime) label.text = "Time Elapsed:\n\(seconds)" label.numberOfLines = 2 } } struct ContentView: View { @State private var showingLevelChooser = false //↓ @StateObject var scene: GameScene = { let scene = GameScene() scene.size = CGSize(width: 300, height: 400) scene.anchorPoint = CGPoint(x: 0.5, y: 0.5) scene.scaleMode = .fill return scene }() var body: some View { ZStack { SpriteView(scene: scene, isPaused: showingLevelChooser) .ignoresSafeArea() VStack { Button("Level Chooser") { showingLevelChooser.toggle() } Spacer() } } .sheet(isPresented: $showingLevelChooser) { VStack { Button("Cancel") { showingLevelChooser.toggle() } Text("Level Chooser") } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Oct ’21
Reply to I want to develop my first app
In summary, I wonder if the app can be developed as planned with the minimum hardware elements (purchase of insufficient machine or upgrade of system specifications) that go into making the three apps I envisioned. It took time to develop, but it would be sad if it was out of service support just before the goal, or if it violated Apple's policy. In my opinion, 2020 M1 MacBook Air (256 GB, 16 GB RAM) and an M1 iPad Pro 11 inch (8 GB RAM) would not be a super bad choice and it might be enough for developing a few, relatively simple apps. But you will soon feel that 256 GB is not enough and you may need to clean up your Mac very often. Anyway, start now, learning Apple's frameworks and programming languages might take far more time that you expect.
Replies
Boosts
Views
Activity
Oct ’21
Reply to Contents of .sheet() are being redrawn after dismiss and not presenting
Is this normal behavior? The ContentView body makes sense to change, but is the sheet's body also supposed to be redrawn when the sheet is not presenting anymore after dismiss? I do not understand what your term redraw means, but if it means body being evaluated, the answer would be: You should not care about that. The property body would be called at any time when the runtime of SwiftUI thinks it is needed, your code should not depend on when or how may times it may be called. It is sort of implementation details of SwiftUI, and may be changed at any time in the future.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to ForEach - Deleting last index causes Index out of bounds error
Can you show a complete code? (It can be simplified, but ready to run.)
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Unexpected non-void return value in void function error in function
What am I doing wrong? When you want to return a value from a closure, the closure must be declared as to return a value. But, the closure type in observeSingleEvent(of:with:) is not declared to return a value. When you want to pass something after some asynchronous operation is finished, one traditional way is using the completion handler pattern. In your case, something like this: func returnusername(completion: @escaping (String?)->Void) { guard let uid = Auth.auth().currentUser?.uid else { completion(nil) return } //guard (Auth.auth().currentUser?.uid) != nil else {return} //<- Duplicate check, is not needed Database.database().reference().child(uid).child("users").child("username").observeSingleEvent(of: .value){ (snapshot) in guard let username = snapshot.value as? String else { completion(nil) return } completion(username) } } You can use it as follows: func someMethod() { returnusername { username in guard let username = username else { return } //Use `username` here... //... } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Change of EnvironmentObject (ObservableObject) pops current view
Can you show a complete code to reproduce the issue?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to VNRecognizeTextRequest doesn't recognize text in iOS 15
Can you provide a completion code to reproduce the issue, in addition to some sample images?
Topic: Machine Learning & AI SubTopic: General Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Undefined symbol error after Xcode 13 update
ReactNative is not a framework of Apple's. You should better visit the supporting site or a community site of it to get better responses sooner.
Replies
Boosts
Views
Activity
Oct ’21
Reply to Non US characters in section headers for a UITableView
How do your show such characters in the section headers? Can you show a complete code to reproduce the issue?
Topic: UI Frameworks SubTopic: UIKit Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Error on launch of app. First seen in iOS 15. What is this?
Are you using NSKeyedUnarchiver explicitly somewhere in your code? If so, you should better update your code to prepare This will be disallowed in the future. It may be used somewhere in the runtime of iOS, in such cases, you may need to ignore the warning.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to XCode 13 - Task not found in scope?
Thanks to Claude31, I could have explored a little more. Instead of import UIKit, import _Concurrency (in addition to import Foundation) will make it. What is odd is we do not need import _Concurrency in app projects. (You should not use import _Concurrency in actual projects, it may be treated as using a private framework.) And one more odd thing is import _Concurrency can be found when I see the generated header for Foundation by Cmd-clicking the line import Foundation.
Replies
Boosts
Views
Activity
Oct ’21
Reply to XCode 13 - Task not found in scope?
Thanks for sharing your experience. I could have reproduced the issue on Big Sur 11.6 (iOS Blank playground). (With additional error: cannot find 'withUnsafeContinuation' in scope.) I do not think this is normal and you should better send a bug report to Apple.
Replies
Boosts
Views
Activity
Oct ’21
Reply to Inconsistency in C double precision comparison
Duplicate post is considered to be a bad manner, you should better care about it. And your question has nothing to do with the WWDC21 session wwdc21-10002, you should use the right tag. And the problem you have experienced, happens because C-double is a binary floating point number type and which cannot represent the value 0.1 precisely. It is the common behavior on all platforms which uses binary floating point, not only on Apple's platform. So, asking it in the Apple's dev forums is not appropriate. You should better find a good site to learn numeric processing.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to Exception NSException * "[<Calculus_area_and_perimeter.ViewController 0x14c506020> setValue: forUndefinedKey:]: this class is not key value coding-compliant for the key calcArea." 0x0000600002799cb0.
When you get a runtime exception with this message, "[<Calculus_area_and_perimeter.ViewController 0x14c506020> setValue: forUndefinedKey:]: this class is not key value coding-compliant for the key calcArea."  iOS runtime is trying to connect an instance declared on storyboard/xib into the @IBOutlet of ViewController named calcArea. Don't you remember you once connected something to an @IBOutlet and name it calcArea, and then renamed it to something else? Anyway, you may need to remove the wrong connection pointing calcArea, and re-connect it to the right @IBOutlet.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to The storyboard opens in xml format.
One possible reason is that you are enabling Code Review: Please check if it really is enabled and try disabling it.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21
Reply to How can you pause a SpriteKit scene from SwiftUI, without reinitializing it every time?
You should better include the code as text, which helps involving more readers. In your code, scene is a computed property, so it is evaluated at each time body is evaluated. Generally, you should better avoid creating a computed property which creates a new instance, especially when the identity is important. Please try something like this: class GameScene: SKScene, ObservableObject { //<- private let label = SKLabelNode(text: "Time Elapsed:\n0") private var lastUpdateTime : TimeInterval = 0 override func didMove(to view: SKView) { addChild(label) } override func update(_ currentTime: TimeInterval) { if (self.lastUpdateTime == 0) { self.lastUpdateTime = currentTime } let seconds = Int(currentTime - lastUpdateTime) label.text = "Time Elapsed:\n\(seconds)" label.numberOfLines = 2 } } struct ContentView: View { @State private var showingLevelChooser = false //↓ @StateObject var scene: GameScene = { let scene = GameScene() scene.size = CGSize(width: 300, height: 400) scene.anchorPoint = CGPoint(x: 0.5, y: 0.5) scene.scaleMode = .fill return scene }() var body: some View { ZStack { SpriteView(scene: scene, isPaused: showingLevelChooser) .ignoresSafeArea() VStack { Button("Level Chooser") { showingLevelChooser.toggle() } Spacer() } } .sheet(isPresented: $showingLevelChooser) { VStack { Button("Cancel") { showingLevelChooser.toggle() } Text("Level Chooser") } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Oct ’21