Post

Replies

Boosts

Views

Activity

Reply to Reverse geocoding rate limit of MKReverseGeocodingRequest compared to CLGeocoder
This might not be the sort of "official" response you're hoping for, but for what it's worth, I just got a rate limit error from MKReverseGeocodingRequest. Just to make sure I didn't miss anything, I just checked every sub page of the docs for that class, I didn't find anything talking about a rate limit. It seems like the error got thrown when I tried to access the mapItems property Here's the error I received: Throttled "PlaceRequest.REQUEST_TYPE_REVERSE_GEOCODING" request: Tried to make more than 50 requests in 60 seconds, will reset in 43 seconds - Error Domain=GEOErrorDomain Code=-3 "(null)" UserInfo={details=( { intervalType = short; maxRequests = 50; "throttler.keyPath" = "REDACTED)"; timeUntilReset = 43; windowSize = 60; } ), requestKindString=PlaceRequest.REQUEST_TYPE_REVERSE_GEOCODING, timeUntilReset=43, requestKind=772} It is true that the mapItems property is labeled as something that throws but I would have expected that to happen if it couldn't find something for that coordinate. I was surprised to see that happen for a coordinate I knew was valid. It would be nice if the docs explained what errors it could throw, and under what conditions. In my opinion, Apple's own example doesn't really set developers up for success either. They use try? await in a task in the view, but if you follow that example, and your list of coordinates got too large, your UI would show un-geocoded entries and there'd be no obvious way to "retry it", which isn't great! I think there's really room for improvement on the docs here.
Dec ’25
Reply to SwiftUI ForEach .onInsert not called for outside drags?
First of all, thanks for this, I've been looking for good sample code that showed how to implement NSItemProvider for drag/drop, and this helped. It looks like only the first onInsert takes effect, I've seen this with other view modifiers like alert() In your code, if I comment out the first onInsert viewModifier, the second one works, and it seems like I can drag pretty much anything into it, including random photos from finder, etc... If you want some code that does one thing on plain text, and then another thing on every other kind of data, check this out If you drag something from "Drag Plaintext", it will print "inserting plain text" If you drag something from "Drag Data" (or drag something from finder/etc), it will print "inserting data" import SwiftUI import UniformTypeIdentifiers var insertedItemCount = 0 struct ContentView: View { @State var data = ["One", "Two", "Three"] var body: some View { HStack { List { ForEach(data, id: \.self) { item in Text(item) } .onMove(perform: { indices, newOffset in data.move(fromOffsets: indices, toOffset: newOffset) }) .onInsert(of: [UTType.data, UTType.plainText], perform: { index, items in for item in items { if item.hasRepresentationConforming(toTypeIdentifier: UTType.plainText.identifier) { print("Inserting plain text") data.insert("Text: \(insertedItemCount)", at: index) } else if item.hasRepresentationConforming(toTypeIdentifier: UTType.data.identifier){ print("Inserting data") data.insert("Data: \(insertedItemCount)", at: index) } else { // I'm not sure when this would happen, even folders and weird file types are still "data" print("Got something weird that isn't data or plain text") } insertedItemCount += 1 } }) } Text("Drag Plaintext") .onDrag { return NSItemProvider(item: "DragMe" as NSString, typeIdentifier: UTType.plainText.identifier) } Text("Drag Data") .onDrag { return NSItemProvider(item: "DragMe" as NSString, typeIdentifier: UTType.data.identifier) } } } } #Preview { ContentView() } Hope that helps
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’25