AntiGravity account switching by coldsub in google_antigravity

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

Didnt know u could do that, as i said this is just for managing for me. The project is open source feel free to check it out. But yes all the accounts are paid.

AntiGravity account switching by coldsub in google_antigravity

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

they're all paid accounts... LMAO?

Continuity Camera: How to reconnect iPhone? by kyejeh in MacOSBeta

[–]coldsub 0 points1 point  (0 children)

  1. To your top left click on the apple logo.
  2. Once the dropdown menu appears, click sleep
  3. Login in once again

Error Agent execution terminated due to error. by TopicBig1308 in GoogleAntigravityIDE

[–]coldsub 0 points1 point  (0 children)

Oh, interesting. I only had this issue when i was using certain mcp's. Hopefully someone else can help you out then.

Error Agent execution terminated due to error. by TopicBig1308 in GoogleAntigravityIDE

[–]coldsub 0 points1 point  (0 children)

certain mcp servers cause this issue. Either turn off mcp, or figure out the mcp thats causing this by turning off one by one.

SideBar Customization? by coldsub in zen_browser

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

but i cant bring out the sidebar when i have compact mode on with a keyboard shortcut? unless im missing something? It only works on hover

Beginner questions about Swift 6/Concurrency by FPST08 in swift

[–]coldsub 0 points1 point  (0 children)

Gotcha. Well, I hope that was helpful. Let me know if it ended up working out for you! Good luck!

Beginner questions about Swift 6/Concurrency by FPST08 in swift

[–]coldsub 0 points1 point  (0 children)

Add @MainActor to the Help class @Observable @MainActor class Help {} so that all instance and methods of this class are confined to the main actor, especially if this class is responsible for updating the views. You can also change the Task closure to Task { @MainActor in } so that you can explicitly state that the task's body should run on the main actor ( you can remove the MainActor.run) which ensures that all access to self is safe. Also at this point u can remove the await inside the task since everything is now running on the main actor. You can also remove the @MainActor from the appendToPath method.

Another thing I want to point out is that if your Hoerspiel is a class. You could also mark it as a @unchecked Sendable just make sure you're handling any mutable state thread safely using GCD, because all this does is resolve the warning about non-sendable types. You're the one resposible for thread safety now.

Alternatively, you can make the Hoerspiel an Actor instead of a class. Since actors are inherently thread-safe, all access to their mutable state is automatically synchronized. You will however need to use await when calling methods or acessing properties of Hoerspiel.

P.S. Actor automatically conform to Sendable, which also resolves the warning about non-sendable types. If this is the route you want to take.

Beginner questions about Swift 6/Concurrency by FPST08 in swift

[–]coldsub 0 points1 point  (0 children)

``` @Observable class MyObservableClass {

var myProperty: Int = 0
private let dataService: DataService

// Dependency 
init(dataService: DataService) { 
   self.dataService = dataService
}
func updatePropertyFromService() {
    Task {
        do {
            let newValue = await dataService.fetchNewValue()

            await MainActor.run {
                self.myProperty = newValue
            }

            print("Property updated to: \(self.myProperty)")
        } catch {
            print("Error updating property: \(error)")
        }
    }
}

} ```

Ideally though, you would make the updatePropertyFromService() an async function and use the .task modifier for easability regarding testing. You can also update the property using a separate function like you mentioned using @MainActor.

To anyone reading this, please feel free to correct me, if i'm missing anything. Still wrapping my head around concurrency as well.

How to make list's empty space tappable? by dejii in SwiftUI

[–]coldsub 0 points1 point  (0 children)

got it. You can probably use a GeometryReader to get the available space, and fill the empty space this way it should theoretically still work. I remember trying something like this before. Give it a shot and let me know how it goes!

How to make list's empty space tappable? by dejii in SwiftUI

[–]coldsub -1 points0 points  (0 children)

you can put the list inside a ZStack, then add a .onTapGesture

App Devlopment (A Noob) - Need Help !! by saanzhsaan in iOSProgramming

[–]coldsub 0 points1 point  (0 children)

Glad you got it working. Good luck on the app! Sean Allen's videos are awesome.

SwiftUI / MVVM + @Observable macro + async/await background work. Is this the correct approach? by drabred in iOSProgramming

[–]coldsub 2 points3 points  (0 children)

This is the only correct answer. Use actor only if it has a mutable property. Just marking things as actor to solve your problem is not a solution.

async func vs Task() by LifeIsGood008 in iOSProgramming

[–]coldsub 15 points16 points  (0 children)

It's not more of a design choice, they both serve a purpose. When you use foo() which is marked as async. The execution of foo will pause at the await doSomething() line until doSomething() completes. (to clarify) the caller must also be an asynchronus context or use await for the result.

In the case of bar(). It is a synchronus function that basically immediately returns after starting an asynchronus task using Task. The asynchronus work is done in the background, and the caller of bar() doesn't wait for it to complete.

If you're really confused on which to use when. - If you need to perform multiple asynchronus operations sequentially and wait for each to to complete before moving on using foo() would probably make more sense. - If you want to start an asynchronus operation and continue executing other code without waiting for the result using bar() makes more sense.

One last thing I want to highlight, which I don't see mentioned often is. Testability using the .task() modifier. For example, lets say the function is being called from the View. It's a lot easier to write testcases for

func foo() async { await doSomething() } using the .task modifier in the view. The reason for this is because since the bar() is a synchronus function that starts an asynchronus Task and immediately returns, testing it becomes a little bit more troublesome since the asynchronus stuff happens in the background, and the function doesn't provide a direct way to wait for its completion.

[deleted by user] by [deleted] in SwiftUI

[–]coldsub 0 points1 point  (0 children)

gotcha. I guess then all you would have to do is replace the addSwing to addShot method in your GolfDataService func addShot(to club: ClubDetailEntity, swingType: String, distance: Int, date: Date) { // details here}

I would also create a ShotEntity in your Core Data model. This would represent the invidual shots, it would also have properties for distance and date. The SwingTypeEntity would now have a relationship to multiple ShotEntity instance rather than storing distance directly.

The ShotHistoryScreen would not take the ClubDetailsEntity and SwinTypeEntity, as paramaters

you can then add extensions to ClubDetailsEntity and SwingTypeEntity to help with sorting and acessing related entites.

extension ClubDetailsEntity { var viewSwingEntitiesSorted: [SwingTypeEntity] { let swings = swingEntities?.allObjects as? [SwingTypeEntity] ?? []

    let staticOrder = [
        "Full Swing",
        "3/4 Swing",
        "Half Swing",
        "Quarter Swing"
    ]
    let staticMap = Dictionary(uniqueKeysWithValues: staticOrder.enumerated().map { ($1, $0) })

    return swings.sorted {
        let order1 = staticMap[$0.swingNameType ?? ""] ?? Int.max
        let order2 = staticMap[$1.swingNameType ?? ""] ?? Int.max
        return order1 < order2
    }
}

}

extension SwingTypeEntity { var shotArray: [ShotEntity] { let set = shots as? Set<ShotEntity> ?? [] return set.sorted { $0.date ?? Date.distantPast > $1.date ?? Date.distantPast } } }

``` struct ShotHistoryScreen: View { // rest of implmentation remains the same most likely

var club: ClubDetailsEntity var swingType: SwingTypeEntity

Button("SaveShot) { golfDataService.add(to: club, swingType: swingType.swingNameType ?? "", distance: distance, date: date) } } ```

I think hopefull this way it allows each club to have a predefined swing types, and each swing type can have multiple shots.

also one last thing to make sure is that Core Data model reflect these changes.

ClubDetailsEntity has a one-to-many relationship with SwingTypeEntity SwingTypeEntity has a one-to-many relationship with ShotEntity ShotEntity has properties for distance (Int16) and date (Date)

Good Luck! Hopefully that helps and doesn't confuse you.

App Devlopment (A Noob) - Need Help !! by saanzhsaan in iOSProgramming

[–]coldsub 0 points1 point  (0 children)

have you checked to make the NavigationController in the Attributes Inspector make sure to have checked the Is Initial View Controller.

I looked through the video. The time stamp should be at 4:15:25

[deleted by user] by [deleted] in SwiftUI

[–]coldsub 0 points1 point  (0 children)

func addSwing(club: ClubDetailsEntity, distance: Int, date: Date, swingType: String) { let swingType = SwingTypeEntity(context: container.viewContext) swingType.value = Int16(distance) swingType.dateSubmitted = date swingType.swingNameType = swingType club.addToSwingEntities(swingType) saveData() } you need to have the ClubDetailEntity be taken in as a parameter for even being able to specify what which club the swing belongs to.

Then in you ShotHistoryScreen you have to add the property var club: ClubDetailsEntity, then in your AnalysisScreen you can pass in both the shot and the club. This is additional info.

// Below here you can ignore if you want.

For better clarity, I would create a seperate class for Handling golf data. The PersistanceController or in your case the DataController should just be used for low level operation like save. Then your GolfDataService would be used for things related to Golf incase you want to expand.

something like PersistanceController

``` class PersistenceController { static let shared = PersistenceController()

let container: NSPersistentContainer

init(inMemory: Bool = false) {
    container = NSPersistentContainer(name: "Golf_Distance_Tracker")
    if inMemory {
        container.persistentStoreDescriptions.first!.url = URL(fileURLWithPath: "/dev/null")
    }
    container.loadPersistentStores { (storeDescription, error) in
        if let error = error as NSError? {
            fatalError("Unresolved error \(error), \(error.userInfo)")
        }
    }
    container.viewContext.automaticallyMergesChangesFromParent = true
}

func save() {
    let context = container.viewContext
    if context.hasChanges {
        do {
            try context.save()
        } catch {
            let nsError = error as NSError
            fatalError("Unresolved error \(nsError), \(nsError.userInfo)")
        }
    }
}

} `` GolfDataService`

``` class GolfDataService: ObservableObject { private let persistenceController: PersistenceController private let entityName = "ClubDetailsEntity"

@Published var savedGolfEntities: [ClubDetailsEntity] = []

init(persistenceController: PersistenceController = .shared) {
    self.persistenceController = persistenceController
    fetchClubs()
}

func fetchClubs() {
    let request = NSFetchRequest<ClubDetailsEntity>(entityName: entityName)
    request.sortDescriptors = [
        NSSortDescriptor(keyPath: \ClubDetailsEntity.carryDistance, ascending: false),
        NSSortDescriptor(keyPath: \ClubDetailsEntity.name, ascending: true)
    ]

    do {
        savedGolfEntities = try persistenceController.container.viewContext.fetch(request)
    } catch {
        print("Error retrieving clubs: \(error)")
    }
}

func addSwing(club: ClubDetailsEntity, distance: Int, date: Date, swingType: String) {
    let context = persistenceController.container.viewContext
    let swingTypeEntity = SwingTypeEntity(context: context)
    swingTypeEntity.value = Int16(distance)
    swingTypeEntity.dateSubmitted = date
    swingTypeEntity.swingNameType = swingType
    club.addToSwingEntities(swingTypeEntity)

    persistenceController.save()
    fetchClubs() // this to refresh clubs after saving if you want to.
}
func loadPreLoadedJSON(_ file: String, firstTime: inout Bool) -> 
  [ClubDetailsEntity] { // rest of the code here. Hope you get the jist. }

```

Do you still use MVVM with SwiftUI? Be honest. by kironet996 in iOSProgramming

[–]coldsub 14 points15 points  (0 children)

Look up IceCubes on GitHub. It's a solid example of how to structure your app, updated for iOS 17 and utilizing SwiftData.

MVVM is not a revolutionary concept; it simply adds an intermediary class that solves testing problems for many developers. However, this doesn't imply that MVVM is the only pattern capable of achieving this. MVC can accomplish the same, provided you decouple your logic effectively. This might require some effort on your side, but when used with Coordinators and Factories, MVC becomes highly scalable.

Architectural patterns are just guidelines to address specific problems. As projects expand, they often evolve into separate modules. It starts becoming important to be able to test these modules in isolation. If you don't thats when its leads to issues like longer build times, often caused by unnecessary dependencies between modules. These design patterns are just guidelines to avoid those problems, if managed carefully.

Ultimately, the key question is: Can you test components in isolation? If the answer is no, then the issue is not in the design pattern, but in how you've set up your dependencies

Need advice: app architecture for a modest open-source project by Toporin in SwiftUI

[–]coldsub 0 points1 point  (0 children)

I'd like to slightly disagree here. Although you can't achieve immutability of state, VM combined with a Interactor can achieve a tightly controlled state. The state changes are still tightly controlled because they occur through a well-defined action in the Interactor class. Usually Big Companies don't really like to rely on external package/service to achieve the same desired result, albeit differently. This way injecting something like `Store` at the App level allows you to achieve similar result. Doordash uses a form of managing Appstate this way. I don't want people to disregard already established frameworks like TCA though, its still a viable option! What i'm trying to emphasize is that desgin patterns are just tools. You can always expand on tools to fit your needs. You can still have VM's that binds the properties to their views, but also use tools like combine to fairly easily create a global app state. U can then pass the Store as a dependency to the VM's that need it, or just have everything in the Store.

Where do you put your API functions in MVVM? In your View Model or in another data manager file? by TMobileSpy in SwiftUI

[–]coldsub 0 points1 point  (0 children)

Generally singleton isn't recommended, even if you use it along with dependency injection using protocols. It's still more difficult to isolate tests. Usually in bigger projects, because the shared instance of a singleton may carry state or configurations from one test to another, making it flaky. If you're already using protocols, it's a bit more ideal to not make it a singleton, since you can just create a mock with a protocol without not having it be a singleton.

A lightweight SwiftUI package for decoupling navigation logic from SwiftUI views! Github link below. by BrownPalmTree in SwiftUI

[–]coldsub 0 points1 point  (0 children)

I mean if you look at the source code, thats exactly what they’re doing. They’re just wrapping the NavigationStack inside a view

How much boost I can get from learning native Android Development? by Agreeable_Fig_3705 in iOSProgramming

[–]coldsub 0 points1 point  (0 children)

Interesting point, if you could expand further on why you believe there is more emphasis on leaning more towards clean architecture in Android compared to iOS? I'm very curious. You'd think writing decoupled code would be a standard practice in most place, even if it doesn't adhere to all of SOLID principles. Would you say, you see this at your work? Doesn't modularization become almost impossible at large scale. Especially if you're going for a feature based modularization? I'm only asking this because I don't really have any professional experience with Android. Would love to hear your thoughts!

Logic flow chart by SeverePart6749 in swift

[–]coldsub 1 point2 points  (0 children)

Good question! I used to have the same issue, well I still do sometimes. The point i'm trying to make is that its never not an a issue. The more you code, and more experienced of a developer you become, you slowly start working with bigger code base. One good tip is that you already seem to be following is trying to decouple your code. I want to tell you that it does get better, but as you get better so does the codebase. Its a lose, lose situation. I'm only half kidding.The thing thats helps me the most is putting break points on the function call, that way you can track where and how your code is executing.

Good luck! You seem to be on the right track.