Post

Replies

Boosts

Views

Activity

Complex view structures are frustratingly too much work
The Java Swing and AWT MVC model made it easy to develop complex UIs with data interactions that were not described readily in a nested layer that SwiftUI demands. The implicit update model of SwiftUI greatly complicates development of applications that often requires nested components to have to know too much about other components and other structures than their own, because button events and other user interactions cannot readily alter state across layers. A button push on one component then has to be knowledgable about state in other components which have to have that state represented as @State or @Binding etc. and this causes all kinds of wiring to be spread all over the place rather than have a more centralized "state management function" that would be able to look at the world and synchronize the UIs state across changes. The fact that the compiler get's lost in the weeds when types and signatures don't match in deeper component structures doesn't help because it makes it doubly hard to do refactoring to raise and lower state management within the structure readily, because the compiler just cannot simply tell you that a function or constructor signature is no longer correct.
1
0
68
1w
Why is SwiftUI so broken and not improving layered UI functionality
Again and and again, I reach the point in a new application where I need to make structural changes in components and my data model, and the SwiftUI compiler fails to compile and just reports "I'm lost in the weeds", with no indication of what it was last working on, aside from a particular level in a multi-layered nested UI. This typically happens when a sub-views construction is not coded correctly because I changed that view and am looking for what broke, by just letting the compiler tell me what is not compatible. This is how refactoring has been done for ages and it's just amazingly frustrating that Apple engineers don't seem to understand nor care about this issue enough to fix it. Why does this problem persist through version after version of SwiftUI? Is no-one actually using it for anything?
1
0
67
1w
SwiftUI against SwiftData is too fragile and error prone
The hardest part of SwiftUI programming is to correctly define the layers of references that you need as your app grows features. When you add Swift data to the mix, it hard to get much of anything correct. I have an application that interacts with the outside world via BLE and LocationManager. I need to preserve used BLE devices and then store their current state in a static Monitor type class structure. This monitor though, needs to have access to some SwiftData elements, and it is not clear from the documentation whether it's preferred to create multiple ModelContainer instances, when they might share a particular types management. This doesn't feel very safe, so it would then make more sense to have a ModelContainer stuck inside of some other static Monitor object that everyone would use to get the single ModelContainer that should be used. All of the context specific stacking of references in SwiftUI creates huge dependency chains, and it make the build of my application, currently to take 10s of minutes sometimes, when I have changes in flux and the compiler cannot make heads or tails out of broken references. We really need to find a way to get the compiler fixed so that as a Recursive Decent parser, it has an easier time finding a terminal state instead of crawling up and down the stack of references looking for a place that it can reach a terminal state. Not using ';' on every statement is a big part of the problem I feel...
1
0
1k
Dec ’23
Location Access While Using not available in Securities for app
I have a new app that I am starting using the Map() component in iOS17. That struct, creates a class which is a CLLocationManagerDelegate, and instantiates a CLLocationManager. In the Target's Info settings, I have Privacy - Location Always and When In Use Usage Description Privacy - Location Always Usage Description Privacy - Location Usage Description all three set. I have another Map app with these set which doesn't have this problem, so I am confused about why, in Privacy & Security->Location Services, the App only shows two selections for Location Services. It shows only "Never" and "When I Share" selections with "When I Share" selected. The location manager reports error: The operation couldn’t be completed. (kCLErrorDomain error 1.) after I get the CLAuthorizationStatus(rawValue: 0) auth=CLAccuracyAuthorization(rawValue: 0) value in public func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) status change in this callback for the delegate and then call: manager.requestAlwaysAuthorization() manager.startUpdatingLocation() What am I missing here?
0
0
569
Oct ’23
Marker with UIImage from CGImage does not show image
I am trying to place a custom image into a Marker using the following code. Marker( coordinate: CLLocationCoordinate2D( latitude: obj.loc.coordinate.latitude, longitude: obj.loc.coordinate.longitude), label: { Label { Text(obj.name) } icon: { Image(uiImage:imageFor(obj.imgSet, idx: obj.img )) } } ) The image is created from images that are 16 pixels high and have various images that are 16 pixels wide. Thus we compute and offset and then extract an image 16x16 at that offset. The Marker appears, but has a square that is white with in color, and the Label text does not appear on the Marker. var s_imgs : [UIImage] = [ UIImage(named: "Symbols")!, UIImage(named: "Symbols2")! ] func imageFor(_ symSet: Int, idx : Int ) -> UIImage { let w : Double = 16 let cgimg = s_imgs[symSet] .cgImage! .cropping(to: CGRect( x: w*Double(idx), y: 0, width: w, height: w))! return UIImage(cgImage: cgimg) } What do I need to do in order to have custom images within the Marker? It would be awesome to just have a View there and have the Marker change diameter to accommodate whatever View I needed to construct. Ideally, I just need the image to work, but that image will have a wide range of colors across all the images and thus I need some flexibility to manage background coloring dynamically as well. .tint could mostly work, but I'd like to but a border on the image with some white space inside the boarder before the image starts.
0
0
465
Oct ’23
Effectively rewrite URL in WKWebView due to poor page implementation
I have a web app that I want to create an app for. This web app returns URLs with hardcoded IP addresses in the URLs as "http://ip-addr/path/to/link". I need to rewrite the URLs to just be "/path/to/link" as they should of been coded. How can I either respond to URL usage with a rewritten URL, or will I have to see the page loaded, and then scan the document and rewrite it? Code examples would be great. Currently, I see the following error when I click on one of these broken links: 2022-09-28 22:11:46.716274-0500 MyApp[64870:4826597] [Process] 0x7fef18012020 - [pageProxyID=6, webPageID=7, PID=64876] WebPageProxy::didFailProvisionalLoadForFrame: frameID=3, domain=NSURLErrorDomain, code=-1004, isMainFrame=1 I can't find a delegate method that is actually being called, so I really don't know how to at least see the load fail and try and get the URL, edit it, and then call the WKWebView to load the edited URL. The primary issue is that this web page can be accessed from an external location and the address in the URL works for that external environment. But, on the local network, where the IP address is different, it also needs to work, and thus the need for the rewrite.
0
0
953
Sep ’22