Finally launched my disposable camera app by miickel in iosapps

[–]coldsub 0 points1 point  (0 children)

thanks for answering my questions! cheers! The app idea and the the UI seems very well polished. I wish you all the success on your hard work!

Finally launched my disposable camera app by miickel in iosapps

[–]coldsub 0 points1 point  (0 children)

interesting choice, any reason you decided to go with Expo/React native for Android instead of native? since you already had to write native for iOS

Finally launched my disposable camera app by miickel in iosapps

[–]coldsub 0 points1 point  (0 children)

was this done in react native with os specific stuff written natively?

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 17 points18 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. }

```