|
I'm working my way through "Hacking with macOS -- SwiftUI Edition 2020-01-31". For Project 2, "Odd One Out", there are some instructions relating to AppDelegate.swift, but there's no such file in my Project 2, I think AppDelegate isn't really a SwiftUI thing? I don't know. Anyway, I don't know how to do
I looked around online for a way to translate this stuff into SwiftUI, but the only stuff I found was just way beyond what I could understand. Did I get the wrong version of the book? Is there a newer version that replaces AppDelegate stuff with...I don't know, ContentView stuff or whatever? |
|
In January 2020, you still had to build SwiftUI apps using the old (UI|App)Kit lifecycle. So, using AppDelegate, etc. At WWDC that year, the SwiftUI lifecycle was introduced and we no longer had to use that stuff. However, you can still use an AppDelegate if you need to, like this:
That should work, but I haven't tried rebuilding those old projects in the newer SwiftUI way of doing things. |
|
Cool, thanks much. But you mention the newer SwiftUI way? What's the newer SwiftUI way to get If not, then could you give me an idea of where to get |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates. Sponsor Hacking with Swift and reach the world's largest Swift community! |
|
Side note: It's always interesting to learn where code came from, but it might be better to learn SwiftUI instead, since that's what Apple will be using for the foreseeable future. Have you checked out Apple's free courses for SwiftUI? [https://developer.apple.com/tutorials/swiftui]. Historically, Apple has also released ebooks that teach you Swift by building an app, but it looks like they haven't made one for Xcode 13. I'm somewhat new to SwiftUI myself, so if you ever need anything, feel free to contact me. |
|
Heh, yes, I've seen Apple's free tutorials. That's why I've spent hundreds of $$$ for Paul's tutorials. But I think you've misunderstood. Learning SwiftUI with a tutorial that takes me through developing an app is precisely what I'm doing, reading Paul's book "Hacking with macOS". The only reason I'm asking the original question is that Paul's tutorial has this old stuff in it, and I figure maybe it's just an editing oversight, and someone can surely tell me what Paul will change that to in his next edition. I'd love your help: tell me how to get the effect of those two flags using proper, modern SwiftUI, and I'll be in your debt. |
|
Or, if you're feeling bored and/or extremely charitable, clone my implementation of his tutorial and tell me why "Play Again" isn't showing up on the blue button. I hacked the app a bit so it will just advance you every time you click an animal; it doesn't matter which one you click. After you get a screen full of animals, when you click on one, you get the end screen, animated opacity, looks great. Except that the blue button is supposed to say "Play Again". Any ideas why not? Cheers |
|
Your button isn't in the correct spot. You'd need to move it to inside the |
|
As far as your other question, is this what you're looking for? https://developer.apple.com/documentation/appkit/nswindow/1419072-movablebywindowbackground?language=objc |
|
I am more indebted to you than I expected. I would NEVER have thought to move that As for the movable window thing, that looks right, but where do I get the window? I've tried Much gratitude to you already |
|
By "newer SwiftUI way", I mean the SwiftUI lifecycle using an I got this to work just fine:
|
|
Thank you so much! Please tell me there is a magical room in Hogwarts where you learned stuff like this. How in the world did you know to circumvent SwiftUI to set that flag? I mean, how did you know not to do it with a view modifier like Again, thank you. My therapist is getting rich from this😆 |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.