@christianselig@mastodon.social avatar

christianselig

@christianselig@mastodon.social

iOS developer, creator of Apollo and Pixel Pals. Previously at ๏ฃฟ. he/him. i love animals. ๐ŸŒฑ

This profile is from a federated server and may be incomplete. Browse more on the original instance.

christianselig, to random
@christianselig@mastodon.social avatar

SwiftUI noob question: I understand why my ViewModel is being initialized twice, but why is it not being deinitialized?

It's created, then a second later when appState.show is changed, the view is recomputed, and view, and its ViewModel, are created anew. Cool! But why is the old one not deinitialized? What's holding onto it?

Sample code: https://gist.github.com/christianselig/d88b1a4d1989b973689ae62d4691162f

christianselig,
@christianselig@mastodon.social avatar

@tclementdev Hmm just as a fun experiment? Button vs Dispatch doesn't change the behavior

christianselig,
@christianselig@mastodon.social avatar

@tjadejong StateObject isn't used in iOS 17 with the new Observable framework

christianselig,
@christianselig@mastodon.social avatar

@khaost It does yeah

christianselig,
@christianselig@mastodon.social avatar

@marcpalmer Alas no, dispatch after doesn't hold a strong reference to its contents

christianselig,
@christianselig@mastodon.social avatar

@rockbart That is just bizarre

christianselig,
@christianselig@mastodon.social avatar

@tclementdev Your guess is as good as mine, this stuff continually confuses me :p

christianselig,
@christianselig@mastodon.social avatar

@jonduenas It shows both as still being in memory, but the references are nothing I can comprehend

christianselig,
@christianselig@mastodon.social avatar

@marcpalmer Unfortunately not, changing it to something simple like a Button yields the same effect :(

christianselig,
@christianselig@mastodon.social avatar

@rockbart So they're just created willy nilly for no reason, and also not deallocated? lol

But also, why wouldn't recreating SpecialView recreate the ViewModel as well, isn't it just bound to the "instance" of the SpecialView?

christianselig,
@christianselig@mastodon.social avatar

@ryanashcraft I'm glad someone appreciates them :p And this code is as fascinating as it is weird, this feels kinda wrong, doesn't it?

christianselig,
@christianselig@mastodon.social avatar

@landonepps It's more so that it's effectively a memory leak, if my ViewModel is somewhat heavy having extra occurrences of it just kicking around isโ€ฆ not ideal

christianselig,
@christianselig@mastodon.social avatar

Hey, this is my first SwiftUI noob question where people are like "Dangโ€ฆ that is kinda weird". I feel like that is somewhat of an accomplishment

christianselig, to random
@christianselig@mastodon.social avatar

iPhone 15 Proโ€™s been my best battery performer by a mile, damn. All MagSafe charging too pretty much

christianselig, to random
@christianselig@mastodon.social avatar

Dumb question, but if I bought one of those "MagSafe stickers" on Amazon, that are traditionally used to give an Android phone MagSafe-like-stickiness, could I instead use it in reverse, and stick it to a non-MagSafe accessory so it would stick to my iPhone?

For instance, say I want to stick it to a banana so the banana magnets to my phone

christianselig,
@christianselig@mastodon.social avatar

@bigzaphod Holy crap, I really need to do this!

christianselig,
@christianselig@mastodon.social avatar

@HilliTech Oooo, perfect! Thank you! None of them seem to have the "neck" part that MagSafe stickers have though, do they?

christianselig,
@christianselig@mastodon.social avatar

@brennansv ah thank you! So sticky side up?

christianselig,
@christianselig@mastodon.social avatar

@nor could you elaborate on that last sentence?

christianselig,
@christianselig@mastodon.social avatar

@d4v what if you flip them over? If not possible, what if you flip the phone 180ยฐ vertically?

christianselig,
@christianselig@mastodon.social avatar

@nor Ah yeah gotcha!

christianselig, to random
@christianselig@mastodon.social avatar

Update on long USB-C cable journey: bought this 15-foot one per recommendations and it's been awesome, not too thick, charges great (only loses 3W versus a 3 ft cable when charging at 100W)
https://mastodon.social/@christianselig/112378065694461950

christianselig,
@christianselig@mastodon.social avatar

@rvkennedy I'm not sure I get the reference ;_;

christianselig, to random
@christianselig@mastodon.social avatar

Choosing a travel backpack is really hard, and I still haven't found one I love, so mostly for my own reference I wrote a long post with thoughts on pretty much every travel backpack out there https://christianselig.com/2024/04/choosing-a-backpack-is-hard/

If you have other recommendations gimme

christianselig,
@christianselig@mastodon.social avatar

@davidolrik Pain to access when wearing though, I don't want to have to stop and take off the backpack to access my water bottle

christianselig,
@christianselig@mastodon.social avatar

@davidolrik Most backpacks I've used just have a water bottle holder on the side, so you can just reach to your side to grab it/put it back

christianselig,
@christianselig@mastodon.social avatar

@davidolrik Not perfect yeah but at least possible

  • All
  • Subscribed
  • Moderated
  • Favorites
  • โ€ข
  • JUstTest
  • magazineikmin
  • Youngstown
  • osvaldo12
  • khanakhh
  • slotface
  • tacticalgear
  • InstantRegret
  • ngwrru68w68
  • kavyap
  • DreamBathrooms
  • thenastyranch
  • everett
  • rosin
  • provamag3
  • Durango
  • GTA5RPClips
  • ethstaker
  • modclub
  • mdbf
  • cisconetworking
  • anitta
  • Leos
  • cubers
  • normalnudes
  • tester
  • megavids
  • lostlight
  • All magazines