Post

Replies

Boosts

Views

Activity

Reply to SwiftUI Table - scroll to selected row
holy smokes that worked. thank you so much. I really appreciate your help! Soln Add an observable for to 'catch' when we need to scroll to a row / DataID: @State private var scrollToTableRow: DataIDClass? Expose a scrolling proxy at the outermost view container (in my case, above a Vstack):  some View { ScrollViewReader { (proxy:ScrollViewProxy) in VStack { ...beautiful UI here ... } Add a scrollToTableRow listener to the Table (nestled inside the Vstack): Table(...){ ... }.onChange(of: scrollToTableRow) { target in unwrap target, scrollToTableRow=nil, withAnimation {  proxy.scrollTo(target, anchor: .top) } In the find Button action, add scrollToTableRow=selection.first I need to figure out a few minor details from here (setting focus to Table; remembering the first DataId in the next chunk). I am glad it worked, though I had my doubts! very cool. thank you thank you.
Jan ’23
Reply to FTP in swift 5
@eskimo hope this is ok : ] Hey fellow thread gals + guys, below is my read-only FTP in native SWIFT5. No libs needed, just copy/paste into a playground and have fun. I forgot about it. https://gist.github.com/const-void/e6d510cea9f884aa0b2aebbd994381d7
Jan ’23
Reply to How would you share common button actions across views?
quick question if it's ok...I'm still learning, so any tips will help! what might I need to look at, to make sure arrays "publish"? I had originally started with a similar pattern as you @Claude31 ... but not as clean (probably where I went astray) typealias Data = [Datum] class StateFactory: ObservableObject { @Published var data:Data = [] @Published var selection:Set<Datum.id> = [] dataLoad(input:Data) { .. } } views deep down for some reason didn't recognize that the @Published Data array had been updated, and so went on blissfuly unaware.. However...if I pulled each array up to the app level...then things worked... func dataLoad(store:inout Data, input: Data) { .. } struct MyApp: App { @State var data:Data = [] var body: some Scene { ContentView { ... } .onAppear { dataLoad(store: &data, input: someFactory() ) } ... I wasn't sure where I went wrong, how how to get StateFactory.data to signal that yo, I have updated I would prefer to control that signal as data may be appended hundreds/thousands of times. But, it could just as well have been some sort of other bug of my own doing. thanks in advance to any who offer tips/tricks!
Jan ’23
Reply to Learning path for MacOS app development
@himav, I am on your journey with you. I thought the apple swiftui tutorials were really solid. I wouldn't get bogged down in Swift, I would start with SwiftUI which will be more fun and creative. for me, starting a tutorial, then my own project, then doing enough of the tutorial allowed me to apply my tutorial learnings to my own project. It helped me grok some previously ungrokkable things. It's super solid, and I was walked you thru most steps from A to Z, which is great. Don't take shortcuts! Google is also a great resource. Also, Apple's documentation now includes practical examples, which are really well thought out and super helpful. Playground is a really nice learning environment and very forgiving. Plus iOS and MacOS have started to converge, so I think now is the best time to learn this stuff. Also remember to be patient with yourself. Do your best, but if it's not fun, set it aside for a while. It's ok if it takes many months or even years. Remember it's only failure if you stop trying :) Finally, I got super stuck and this forum helped me when it was most dire. So keep hope alive my friend!
Feb ’23
Reply to Prevent disabling System Integrity Protection via MDM
what you may be looking for is a policy audit & enforcement "endpoint protection" solution; more than likely you want your devices to go offline if the policy audit fails for any reason, so not sure this is the right forum. It's a bit belt and suspenders, but users (executives) can be quite crafty; however, when google and email stop working and they have to wait to wipe their now untrusted device to get back online, the behavior better matches what you are looking for.
Feb ’23
Reply to Is this bad practice?
Great advice in this thread. For static data, what do folks think about moving them out of the class and into a structure? The data is global, or at least common across all class instances. Not always feasible. However, this way multiple static structures can be located in a "Statics.swift" and reduce class line counts. import Cocoa ///relocate static data away from instance specific data struct OurFavorites {     static var food = "Orange"     static var number = 21     static var flag = true } class MyLikes {     /// unnecessary but helpful:  tightly couple a class's static data  to the class instance     let ourFavorites = OurFavorites.self     var myFavoriteWord:String          init(myFavoriteWord:String) { self.myFavoriteWord = myFavoriteWord }     ///without ourFavorites,  OurFavorites.food works too.     func display() {         print("\(myFavoriteWord) \(ourFavorites.food)")     } } var a = MyLikes(myFavoriteWord: "Happy") var b = MyLikes(myFavoriteWord: "Nice") a.display() b.display() OurFavorites.food="Apple" a.display() b.display()
Feb ’23
Reply to Is this bad practice?
hey @GMacD53 I don’t understand why the answers are about structs versus enums versus……. when my question was about reformatting the code into chunks and in line? Class properties are code. In general, over time, you may find you want to modularize your code to simplify what the compiler / git has to do on code change.. Move static class properties into a struct -> new file Move the global-> new file. Refactor common code into helper functions -> new file These all reduce the number of lines in your class. Xcode is very powerful as well - code folding, auto-indent, class browser, holding down the command key while moving the mouse, right click -> find symbol etc to quickly navigate have all helped me. have fun + good luck!
Feb ’23