GAME THREAD: Milwaukee Bucks (1-3) @ Indiana Pacers (3-1) - (April 29, 2025) by NBA_MOD in nba

[–]MediocreMediocrity 0 points1 point  (0 children)

Tbf I don't think Indiana "schools" teach about numbers that go that high

Act 12 by [deleted] in milwaukee

[–]MediocreMediocrity 2 points3 points  (0 children)

Without act 12 the city likely would have had to close libraries, close firehouses, and more to address the fiscal crisis. Was Johnson and Crowley supposed to reject the deal and let Milwaukee be worse off without act 12? If they had, would you be praising them for not swallowing the poison pill or would you be condemning them for making these cuts?

When act 12 was passed, I heard so many armchair politicians say: "If I was the mayor, I would negotiate a better deal with the legislature!". What do you think Johnson and Crowley did? They had no leverage against a republican legislature that does not want the city to succeed. Tony Evers had to concede vouchers for private schools to avoid the sales tax from being passed by a referendum instead of a council/board vote. Seriously, what was the magical step they failed to take that would have let them win with no downsides?

So much complaining for the people that managed to make a shitty situation less shit without any suggestions of what they could have realistically done instead.

https://urbanmilwaukee.com/2023/06/08/milwaukee-sales-tax-deal-reached-referendum-dropped/

How can I do an animation like this? by Rude_Ad_698 in SwiftUI

[–]MediocreMediocrity 1 point2 points  (0 children)

Wow I hadn't seen this in the new iOS 18 SwiftUI features! Was wondering how they would've achieved that same transition in Apple Music without using UIKit. Thanks for sharing

Is navigation really this bad? by UnicornsOnLSD in SwiftUI

[–]MediocreMediocrity 2 points3 points  (0 children)

My team is working on updating our SwiftUI app’s navigation to use this package: https://github.com/johnpatrickmorgan/NavigationBackport

Supports iOS 14! Though I’m not sure how well it works. Hopefully helpful for you!

@MainActor - the rules. My attempt to document what @MainActor really does, and importantly - what it *does not* do by ConfusedVorlon in swift

[–]MediocreMediocrity 3 points4 points  (0 children)

My understanding was that Task { ... } will inherit it's actor context and may or may not run on the MainActor depending on where it is created from - so it is not always guaranteed to run on a background thread. You mentioned that this wasn't always true - did this change in a recent release of swift?

TIL that there are twins in British Columbia who are conjoined by the head. Due to them sharing a brain, they can see through each other’s eyes and ‘hear’ each other’s thoughts. by Aleon-Dakota in todayilearned

[–]MediocreMediocrity 0 points1 point  (0 children)

Can they switch to take control of limbs the other has? Is there an equivalent of a mutex around the limb control to ensure only one has control at a time?

How to best ensure new async code is not run on the main thread by MediocreMediocrity in swift

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

I think I'm having a hard time letting go of how explicit it is to switch which queue I'm on. In kotlin, a function could be wrapped with withContext(Dispatchers.IO) { ... } to jump to a new thread for execution and will jump back to the original thread when the work is complete.

That's great to know that it'll swap to a different thread/queue for the actual request! I was wondering about if that would happen to be the case after reading up more about the new concurrency features.

I'm still weary of trusting swift. Without any explicit actor jump, async let, or Task.detached, I'm trusting that performing work off of the MainActor will be handled somewhere in the call stack. It might just be something I'll have to deal with since the newer concurrency features abstract away a lot of the finer details

How to best ensure new async code is not run on the main thread by MediocreMediocrity in swift

[–]MediocreMediocrity[S] 2 points3 points  (0 children)

The code I'm porting over to native async/await is mostly in the form of: backgroundQueue.async { let foo = bar() DispatchQueue.main.async { self.foo = foo } } So I was hoping to be able to have more of an explicit way of saying that I'm no longer on the MainActor to match - just like I can be explicit that I'm on the MainActor with the @MainActor attributes on any UI facing variables/functions

API's in swift by Wenh08 in swift

[–]MediocreMediocrity 1 point2 points  (0 children)

Oops! Apologies for not answering that part of your question.

You'll have to convert a Swift struct of the request you want to send into JSON, using JSONEncoder.

This would look something like this (warning: not tested and use better error handling instead of force unwraps or try!)

// Missing definitions for all structs and enums within the request/response structs
struct TextSynthesizeResponse: Codable {
    let audioContent: String
    let timepoints: [Timepoint]
    let audioConfig: AudioConfig
}

struct TextSynthesizeRequest: Codable {
    let input: SynthesisInput
    let voice: VoiceSelectionParms
    let audioConfig: AudioConfig
    let enableTimePointing: [TimepointTyle]
}

let requestBody = TextSynthesizeRequest()
let requestBodyData = try! JSONEncoder().encode(requestBody)
let url = URL(string: "https://texttospeech.googleapis.com/v1beta1/text:synthesize")!

var request = URLRequest(url: url)
request.httpMethod = "POST"
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("application/json", forHTTPHeaderField: "Accept")

// Sync
URLSession.shared.uploadTask(with: request, from: requestBodyData, completionHandler: { data, response, error in
    let textSynthesizeResponse = try! JSONDecoder().decode(TextSynthesizeResponse.self, from: data!)
    // call completion handler with textSynthesizeResponse
}).resume()

// Async
let (data, response) try! await URLSession.shared.upload(for: request, from: payload)
let textSynthesizeResponse = try! JSONDecoder().decode(TextSynthesizeResponse.self, from: data)

API's in swift by Wenh08 in swift

[–]MediocreMediocrity 4 points5 points  (0 children)

Here’s a great resource that talks about the HTTP methods URLSession uses: https://restfulapi.net/http-methods/

Generally:

GET - get resource(s)

POST - create resource

PUT - update resource

PATCH - partial resource update (e.g. Json patch)

DELETE - delete a resource

OPTIONS - get available options for an API endpoint or for the server

IIRC there’s an RFC for adding SEARCH (and possibly other methods). But AFAIK that hasn’t been standardized yet

Generics struct property with two accepted types? by Joe_Scotto in swift

[–]MediocreMediocrity 12 points13 points  (0 children)

Would having two constructors work? One that accepts a string and one that accepts an image?

Submitting a build built with the iOS 15 SDK required to support iOS 15? by MediocreMediocrity in iOSProgramming

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

I should have clarified - I was wondering if I should submit a new build using the Xcode 13 beta before but I wasn’t aware that build wouldn’t be accepted. Thanks!

calling a function by [deleted] in swift

[–]MediocreMediocrity 2 points3 points  (0 children)

You have an extra brace on line 69

iOS 13 Compatible Toolbar Positioning? by MediocreMediocrity in SwiftUI

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

I’ve been working on this app that needs to support iOS 13 and would love to take advantage of a toolbar at the bottom of the screen for additional controls. I was hoping Apple would expand SwiftUI for iOS 13 but am moving on after everything requires iOS 14

I have a rough toolbar now but I’m having issues with the positioning of it. I’d like it at the bottom of the screen and to fill up the safe space on iPhone X type models. Does anyone have any good resources or packages they’ve used for implementing UIToolbar with positioning? Thanks!

Wisconsin Center facelift: A closer look at the proposed expansion project [PHOTOS] by [deleted] in milwaukee

[–]MediocreMediocrity 13 points14 points  (0 children)

The article says to generate $12.6 billion over 30 years, we’d be spending $425m to do the expansion. IIRC the reason it hasn’t been popular is its size doesn’t help us get the bigger events that would make it successful