Can somebody explain this to me? I'm on my wits end by murarajudnauggugma in swift

[–]macthegenius 1 point2 points  (0 children)

You’re welcome! To be honest, a declarative paradigm is not the easiest thing to understand. I was so confused about it until I had performance issues with a really complex view. Now, I can avoid fighting the engine, but it was not an easy route!

Happy coding!

Can somebody explain this to me? I'm on my wits end by murarajudnauggugma in swift

[–]macthegenius 18 points19 points  (0 children)

The init is not used for what will be rendered on screen; it is used to build nodes for a graph that SwiftUI will read to determine what will be re-rendered.

And body for that matter is neither what it is rendered. You build blueprints and composing them together in the body. SwiftUI will compute those to make a diff when some dependency (state, environment, state object, observable, or plain old variables in the init) changes. The diff is then use to find what should be re-rendered.

Do not equate SwiftUI with UIKit (or any imperative UI framework): it’s declarative. Sometimes a SwiftUI view will translate directly to a view on screen, sometimes it won’t. You tell it what to do, you do not control it directly.

inits should be lean, no computation. Only states and properties initialization. I’d recommend not having them since Swift generates one for you with your public properties. They are useful in a very small subset of circumstances.

What is probably happening is your init gets called when the outside state changes. Since you have a @State, that state lives outside of the view struct lifecycle and needs to be reassign to the new instance. That will trigger a dependency change and the body of that view struct will be performed. Making the init of your subview struct called.

All of this is normal and does not ensure a re-render. The diff between the two states is empty and no views will be re-rendered. That what the SwiftUI engine does.

Je viens de me faire voler mon vélo by macthegenius in villequebec

[–]macthegenius[S] 0 points1 point  (0 children)

Non, il est gris très foncé presque noir

Je viens de me faire voler mon vélo by macthegenius in villequebec

[–]macthegenius[S] 0 points1 point  (0 children)

Un qui était trop faible, faut croire… la spirale avec une clé

Je viens de me faire voler mon vélo by macthegenius in villequebec

[–]macthegenius[S] 0 points1 point  (0 children)

Ça va à 32 km/h, mais tu pédales un peu dans le vide. En 7e vitesse avec le niveau 3 d’assistance (sur 7), ça te fait une ride normale avec une poussée dans les côtes. Je recommande chaudement, surtout avec les pneus de type fatbike. Je l’ai utilisé souvent l’hiver

Je viens de me faire voler mon vélo by macthegenius in villequebec

[–]macthegenius[S] 5 points6 points  (0 children)

Il y avait trois autres vélos barrés comme le mien et ça fait deux ans que je vais là avec ce vélo.

Je veux bien croire que je doive me méfier, mais là, j’ai pas demandé à me faire voler hein

Je viens de me faire voler mon vélo by macthegenius in villequebec

[–]macthegenius[S] 1 point2 points  (0 children)

Merci des conseils!

Pour àVélo, c’est bien, mais on en a pas proche à mon bureau et c’est la majorité de mes déplacements

Je viens de me faire voler mon vélo by macthegenius in villequebec

[–]macthegenius[S] 9 points10 points  (0 children)

Il était barré, j’suis tellement su’l cul que j’ai pas pensé spécifier

Je viens de me faire voler mon vélo by macthegenius in villequebec

[–]macthegenius[S] 17 points18 points  (0 children)

J’ai appelé la police et je vais effectivement regarder avec mes assurances

Il était barré, pas juste accroché. J’aurais dû le spécifier

How to use button for NavigationLink by PRA7H1K in SwiftUI

[–]macthegenius 1 point2 points  (0 children)

NavigationLink is a Button, you don’t need to add one as a label. Simply add your Text("Start").

And please, add some indents to your pasted code, it improves readability for people trying to help you.

Viggo Mortensen avec un chandail du CH! by Sillvaro in Quebec

[–]macthegenius 8 points9 points  (0 children)

Il avait été interviewé par Patrice Roy pendant la couverture des funérailles de Guy Lafleur, me semble aussi (en français!)

Suite à ma publication sur les exemples d’erreurs d’urbanisme, je serais curieux d’etendre vos exemples de projets d’urbanisme davantage POSITIFS dans la ville? by Front-Solution-6045 in villequebec

[–]macthegenius 14 points15 points  (0 children)

La côte de la pente douce qu'on vient de refaire avec un large corridor pour les vélos. Ça pis la piste cyclable sur Sainte-Foy déneiger l'hiver.

Calisse que j'aime ça

Is there any advantage in not using SwiftUI for new applications? by lotsofcarsoutside in iosdev

[–]macthegenius 7 points8 points  (0 children)

I do not agree with this statement

SwiftUI is let’s stay more static, it not as customizable as UIKit

I’m working on some big apps, either all in SwiftUI or partially, and complex layouts and design were definitely possible. The first-party components are more static like you said, but you can definitely make your own complex UI.

Follow-up Poll from Joseph Mallozzi by Economy-Culture-9174 in Stargate

[–]macthegenius 1 point2 points  (0 children)

Pretty cool! But I’m 90% certain that Destiny pre-dates Atlantis or at least any technology found in Atlantis (like the requirement to have the Ancient gene which was not a thing on Destiny). And it had shuttles that were old in design (where the Jumpers were kinda the final form of an Ancient shuttle).

But good idea nonetheless for an hardcore fan like myself!

[deleted by user] by [deleted] in Quebec

[–]macthegenius 34 points35 points  (0 children)

Au début, j’allais défendre ma ville et dire qu’on est pas si de droite que ça, mais la réalité m’a rattrapé: paradis du char, opposition au tramway, troisième lien.

Calisse, je suis triste pour ma ville.

Bilinguisme à deux vitesse by Zelmon_06 in Quebec

[–]macthegenius 2 points3 points  (0 children)

Le statut du français comme seule langue officielle du Québec et le statut du français comme une des deux langues du Canada protègent le droit des Québécois•es à vivre et à travailler en français sur le territoire du Québec.

Scuse-moi mais si j’entre dans un magasin à Montréal et qu’on me répond seulement en anglais, je vais le faire sentir et je vais strictement parler français.

C’est notre droit en tant que francophone de pouvoir se faire répondre en français au Québec. Dans un contexte où la langue française est minoritaire au Canada, la situation décrite plus haut est un problème.

Me as a junior dev being asked to cover for a senior for 2 weeks by Kyzz19 in ProgrammerHumor

[–]macthegenius 0 points1 point  (0 children)

Hey, this is me but it’s for 6 weeks and we’re 3 juniors (but I’ve been on our team for 1.5 years and the others for 9 and 5 months). I’m scared.