|
I'm trying to customize a TabView, and I'm having some trouble understanding how the component works (it's dumb as hell for Apple to not make SwiftUI open-source to get it out of the buggy black-box phase faster)code:
|
# ? May 28, 2022 19:41 |
|
|
# ? May 22, 2024 14:07 |
|
What's the good and smart way to initialize a ViewModel that depends on other variables within a view?code:
|
# ? Jun 3, 2022 11:29 |
|
Can you make a proper initializer for MyView that takes a Coordinator, then initialize the view model from there? (Though I'm not sure if the AppData instance is available at that point.)
|
# ? Jun 3, 2022 14:22 |
|
uncle blog posted:What's the good and smart way to initialize a ViewModel that depends on other variables within a view? First, just note that you shouldn’t initialize an ObservedObject. That should be @StateObject if you are instantiating the class inside the view. There are two problems. One, apple has left us with no approved way of doing this, and we are hoping for a change to _newVM = StateObject(wrappedvalue: VM(params)) at WWDC next week. Second, the only half-good unapproved solution doesn’t work because you are using an EnvironmentObject. People seem to feel it’s best practice to not have views create their own view models, but instead to pass those in using some mechanism. If you can, it’s probably a better design to have myViewModel instantiated somewhere else and either put into the environment for MyView, or passed in. This sidesteps the whole problem. Find a place where these entities all exist and instantiate MyViewModel there. Sometimes I’ve found that there wasn’t a good way to do all that, and what I’ve done is made appData an optional inside myViewModel. Then, inside MyView, you can assign it using .onAppear (EnvironmentObjects exist within .onAppear closures). It makes MyViewModel ugly because you need to deal with the optional, but, it’s the only way I know to get something from an @EnvironmentObject into a new object inside a view. Without the EnvironmentObject (like with your coordinator) you can just create your StateObject inside the view init block. See what I’m doing with the coordinator below. Apple docs say not to do this, but they don’t give us anything else. code:
|
# ? Jun 4, 2022 00:56 |
|
Graniteman posted:Sometimes I’ve found that there wasn’t a good way to do all that, and what I’ve done is made appData an optional inside myViewModel. Then, inside MyView, you can assign it using .onAppear (EnvironmentObjects exist within .onAppear closures). It makes MyViewModel ugly because you need to deal with the optional, but, it’s the only way I know to get something from an @EnvironmentObject into a new object inside a view. Could you not safely do code:
|
# ? Jun 4, 2022 01:04 |
|
101 posted:Could you not safely do Yeah, I’ve done that, too. If you can be certain that nothing in your view model initializer will use AppData it should be fine I guess, but it feels a little more risky than a normal force unwrap to me since I don’t understand the exact sequence between a view calling it’s initializer (creating the class with a nil appData), any opportunity for code to run in the viewmodel, and when the .onAppear closure finally runs and populates the optional permanently. Since I don’t understand the risk, I would lean toward leaving it optional instead of permanently force-unwrapped.
|
# ? Jun 4, 2022 01:36 |
|
am i burnt out or was wwdc kind of meh this year?
|
# ? Jun 10, 2022 16:51 |
|
depends on whether weatherkit actually works in japan or not
|
# ? Jun 10, 2022 17:00 |
|
KidDynamite posted:am i burnt out or was wwdc kind of meh this year? I'm feeling more sad about "looking forward to using this in a few years when I bump a min sdk requirement" than usual, which is maybe a sign that I'm more excited about what I've seen so far.
|
# ? Jun 10, 2022 19:12 |
|
I like the new SwiftUI charts and the modifiers to the SF symbols. I feel like I'll get a lot of mileage out of that. I didn't get to catch as much as I'd hoped, but I have bookmarks to go back to when there's time. The
|
# ? Jun 10, 2022 19:39 |
|
There's a bunch of nice low-level improvements that you probably don't need to take any actions regarding, a bunch of SwiftUI improvements, and not a lot in the middle. Xcode 14 seems to be exactly what I've been wanting them to do: lots of significant performance improvements and general bug fixing rather than focusing on flashy new features, but if you weren't previously getting mad at the state of Xcode that's probably not exciting to you.
|
# ? Jun 10, 2022 19:48 |
|
RoomPlan looks cool, I'm excited to play around with that. Charts sounds promising, also glad they're improving on SwiftUI navigation. haven't watched any sessions yet to see what else is new/improvedpokeyman posted:I'm feeling more sad about "looking forward to using this in a few years when I bump a min sdk requirement" than usual yeah this is always the worst part. here's to 2024/2025
|
# ? Jun 10, 2022 20:00 |
|
pokeyman posted:I'm feeling more sad about "looking forward to using this in a few years when I bump a min sdk requirement" than usual, which is maybe a sign that I'm more excited about what I've seen so far. 100% SwiftUI and related libraries need to be back ported and available via SPM. The bugs from version to version are hard to deal with, so many version checks in our app.
|
# ? Jun 10, 2022 20:53 |
|
one dumb thing I'm excited for as a developer and not a user: dropping support for 1st gen iPhone SEs no more 320pt screens! (iiuc)
|
# ? Jun 11, 2022 00:08 |
|
rip Three20 framework
|
# ? Jun 11, 2022 00:57 |
|
As a library developer I'm very excited by bitcode and armv7 loving off, but most people aren't going to care about that.
|
# ? Jun 11, 2022 02:21 |
|
pokeyman posted:I'm feeling more sad about "looking forward to using this in a few years when I bump a min sdk requirement" than usual, which is maybe a sign that I'm more excited about what I've seen so far. Just can bump the SDK guard your use of features newer than your deployment target, your users will love it.
|
# ? Jun 11, 2022 08:01 |
|
Froist posted:I don’t want to make a baseless claim without doing my research so I won’t say it was the first, but QML was surely one of the early ones. I worked on the framework itself way back in my career - dates get fuzzy at this point but wiki says it launched in 2009 which feels about right. Older post but gently caress it, SA moves slow these days, and I have BIG OPINIONS about Qt. Its a loving dream framework, it really is. QML when you put the effort into a design can be made to look amazing, it feels like its the declarative display language HTML could have been if HTML wasnt designed by a physicist and then fed through 30 years of hell committees, and the framework actually makes C++ into a language that feels comfortable and ergonomic to work in. Seriously, look up its networking classes, its just so good. But the loving licensing, good grief. I would *love* to use it as my do-anything toolkit. Hell the netwoking class alone makes it a serious contender for writing servers, and QML works well on pretty much anything. But the licensing. Its completely beyond the reach of low budget hobbyist and one man band coders. And thats a shame, because an MIT open sourced QT would change *everything* duck monster fucked around with this message at 03:10 on Jun 17, 2022 |
# ? Jun 12, 2022 17:00 |
|
Maybe I’ve got my desktop application developer blinders on, but what situation would prevent one from dynamic linking the libraries and following the LGPL license?
|
# ? Jun 12, 2022 17:55 |
|
take boat posted:one dumb thing I'm excited for as a developer and not a user: dropping support for 1st gen iPhone SEs iphone 8/se2/etc have the same res as og se when display zoom is on iirc
|
# ? Jun 12, 2022 22:25 |
|
vote_no posted:Maybe I’ve got my desktop application developer blinders on, but what situation would prevent one from dynamic linking the libraries and following the LGPL license? It may have improved somewhat in recent times, but I dont believe the mobile ports are LGPL edit: It appears thats not true anymore. Neato. All it needs now is someone to port the Crystal-lang wrappers and the language itself to IOS and Android and we'd have gods own mobile dev toolkit. duck monster fucked around with this message at 03:12 on Jun 17, 2022 |
# ? Jun 17, 2022 02:51 |
|
I have a viewmodel which gets passed an instance of an AppData class. And I want the viewmodel to trigger an update of the appData every x seconds. Have tried a few things, but nothing seems to work properly (or either makes the CPU go crazy). This is a basic representation of the setup I'm working with: code:
Let me know if you need to see any more of the code, or more specific examples. Not really sure how to progress from here
|
# ? Jun 20, 2022 08:42 |
|
do you need the timer to be in the view model? could try placing the timer in ChildView, put an .onReceive on your ForEach, and expose a function from your ChildVM that lets ChildView ask for an update.
|
# ? Jun 22, 2022 14:14 |
|
hey I have 3k I can spend and get reimbursement from work. What swift resources would y’all spend this money on? Bonus points if it will help land a new job. Already have objcio and pointfree on the list.
|
# ? Jul 19, 2022 13:16 |
|
KidDynamite posted:hey I have 3k I can spend and get reimbursement from work. What swift resources would y’all spend this money on? Bonus points if it will help land a new job. Donny Wals has a couple books. I've not read them but their blog is great, so maybe worth a look.
|
# ? Jul 19, 2022 15:43 |
|
it's not recent and covers more Objective-C than Swift, but the best iOS app development book I've read to date is https://www.amazon.com/iOS-macOS-Performance-Tuning-Objective-C/dp/0321842847 and I'd recommend buying a copy pointfree is good if you're not familiar with how to build an iOS app in a React/Redux-style architecture, but if you are I don't know I'd recommend it. it's not a bad use of work reimbursement though
|
# ? Jul 20, 2022 00:32 |
|
Does a widely used pattern exist for triggering pop-up views overtop all views in a swiftui app? I have one with a lot of views and each view in turn has a some sub-views in which I need to trigger a pop-up display over over the child+parent view. Mostly to trigger help messages and informative things. I've created a custom PopUpView and overtop the main parent views, I have something like: code:
|
# ? Jul 20, 2022 19:06 |
|
Environment and preferences are the tools you want if you need views to communicate through the hierarchy without manually passing things around.
|
# ? Jul 21, 2022 02:26 |
|
Thanks. I'll check out Environment. I recall seeing that used in CoreData.
|
# ? Jul 21, 2022 16:29 |
|
I haven't used Core Data so maybe they also have something called the environment, but to be clear I was talking about SwiftUI's concept of environment which is its own thing unrelated to Core Data. Here's an article that goes over it and shows how to create your own custom environment values: https://useyourloaf.com/blog/swiftui-custom-environment-values/
|
# ? Jul 21, 2022 19:13 |
|
dizzywhip posted:I haven't used Core Data so maybe they also have something called the environment, but to be clear I was talking about SwiftUI's concept of environment which is its own thing unrelated to Core Data. Here's an article that goes over it and shows how to create your own custom environment values: https://useyourloaf.com/blog/swiftui-custom-environment-values/ That article and entire site is a pro click. Much appreciated.
|
# ? Jul 22, 2022 01:39 |
|
If I revoke my Development and Distribution certificates, apps already on the App Store will be unaffected?
|
# ? Aug 16, 2022 13:29 |
|
uncle blog posted:If I revoke my Development and Distribution certificates, apps already on the App Store will be unaffected? Correct.
|
# ? Aug 16, 2022 13:58 |
|
Our app got updated to iOS 13, making URLSession.init deprecated. I'm tasked with updating a bunch of tests that got broken by this deprecation. I'm not sure what a good, clean way to rewrite this mocksession, so that it can easily provide a URLSession for our APIClient? code:
code:
|
# ? Aug 23, 2022 13:03 |
|
Shortest answer is define your own init and call the designated super.init, which is probably init(configuration:delegate:delegateQueue:). Maybe better answer is make a protocol Session, declare the methods of URLSession that you use, then conform URLSession to it. Make your MockSession conform to the protocol instead of subclassing. Then have your ApiClient take an instance of the protocol instead of a URLSession.
|
# ? Aug 23, 2022 15:53 |
|
Thanks, I’ll look into that!
|
# ? Aug 24, 2022 21:06 |
|
edit: made it work -ish
uncle blog fucked around with this message at 14:37 on Aug 25, 2022 |
# ? Aug 25, 2022 13:19 |
|
Yeah go with making a protocol IMO and have URLSession and your MockSession conform to it via an extension IMO. I wish they'd built the Foundation APIs to be protocol-based but what can you do at this point .
|
# ? Aug 27, 2022 09:33 |
|
ultramiraculous posted:Yeah go with making a protocol IMO and have URLSession and your MockSession conform to it via an extension IMO. I wish they'd built the Foundation APIs to be protocol-based but what can you do at this point . related WWDC session: https://developer.apple.com/videos/play/wwdc2018-417/?time=539
|
# ? Aug 27, 2022 14:44 |
|
|
# ? May 22, 2024 14:07 |
|
I feel like I'm going crazy. Every time I try SwiftUI, I hit some dumb but huge hurdle so quickly. code:
The tap gesture takes precedence over the onDelete so the onDelete almost never gets triggered or if it rarely does, it's at the same time as the tap gesture. I've tried using swipeActions instead, both with a ForEach and just a List (they don't work on just a list) and the issue persists. Am I missing something, or am I giving up on SwiftUI for another few years?
|
# ? Sep 5, 2022 10:27 |