Post

Replies

Boosts

Views

Activity

Reply to can I use the san francisco font in my company's logo?
If you open the Font Book app on your Mac and choose the font you want to use, you can see the license terms of the font: As far as I read the license of SF Pro Rounded, I could not find any statements you could use it in your company's logo. Instead, I could find this: You agree that you shall not use or incorporate the Symbols or any substantially or confusingly similar images into app icons, logos or make any other trademark use of the Symbols.  I'm not a legal expert, so you may contact to some legal or licensing expert and show all the terms in the license. But generally, you cannot use Apple's fonts other than using it in your apps.
Topic: Design SubTopic: General Tags:
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