Post

Replies

Boosts

Views

Activity

Reply to Closure containing a declaration cannot be used with result builder 'ViewBuilder
Do not nest Content_Preview nor WebView into ContentView. // //  ContentView.swift // import SwiftUI import WebKit import UIKit // ** DO NOT NEST ** struct ContentView_Previews: PreviewProvider {     static var previews: some View {         ContentView()     } } struct ContentView: View {     let webView = WebView(request: URLRequest(url: URL(string: "https://www.apple.com")!))     var body: some View {         VStack {             webView             HStack {                 Button(action: {                     self.webView.goBack()                 }) {                     Image(systemName: "arrowshape.left")                         .font(.title)                         .foregroundColor(.blue)                         .padding()                 }                 Spacer()                 Button(action: {                     self.webView.goHome()                 }) {                     Image(systemName: "house.fill")                         .font(.title)                         .foregroundColor(.blue)                         .padding()                 }                 Spacer()                 Button(action: {                     self.webView.goForward()                 }) {                     Image(systemName: "arrowshape.right")                         .font(.title)                         .foregroundColor(.blue)                         .padding()                 }             }         }     } } // ** DO NOT NEST ** struct WebView: UIViewRepresentable {     let request: URLRequest     private var webView: WKWebView?     init (request: URLRequest) {         self.webView = WKWebView()         self.request = request     }     func makeUIView(context: Context) -> WKWebView {         return webView!     }     func updateUIView(_ uiView: WKWebView, context: Context) {         uiView.load(request)     }     func goBack() {         webView?.goBack()     }     func goForward() {         webView?.goForward()     }     func goHome() {         webView?.load(request)     } }
Feb ’23
Reply to How to populate a pixel buffer much faster?
Right now, you're running in O(n^2), and as your screen size gets larger, 1080p vs 2K vs 4k vs 8k, the lengthier your runtime becomes. Moving this to Metal or OpenGL will be the better option since GPUs are faster than CPUs. Explore changing from for loops to something recursive. The BGRAPallet and the pixel buffer ptr should also be the same size, or the first N BGRAPallets are processed, then you're left just updating the position 0 of pixalBufferPtr for another million plus cycles.
Topic: Programming Languages SubTopic: Swift Tags:
Jan ’23
Reply to Apple Weather app vs Weather Pro from Luni - copycat ?
How else do you propose Weather Apps present the information? How else do you propose Wendys and Mac Donalds make their burgers? And for the records, the Apple Weather App doesn't use a tab bar controller. Something tells me you're an ex-disgruntled employee of Luni. How else would you have known to point out something like this? It looks pretty petty on your part.
Jan ’23
Reply to SwiftUI: reference types leaks memory when used in State property wrapper.
No need for the 2nd init of simple in on Appear, so yes, it will leak memory as each instance is eventually taken care of by ARC.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’23
Reply to How to get IP address of interface a packet will sent on on iOS
These BSD APIs were neutered years ago by apple for privacy reasons to avoid using an IP or mac address tracking a user as a replacement to the once available unique device identifier. You will have to find the IP address by some other means maybe having the server detect the incoming IP address.
Replies
Boosts
Views
Activity
Feb ’23
Reply to Crash on updateValue for Dictionary
cache[uid] = model
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Feb ’23
Reply to iOS 16: SwiftUI - Crashed: EXC_BAD_ACCESS KERN_INVALID_ADDRESS
Just make sure the API being used meet the minimum iOS level. Set your deployment target to the latest iOS 16; if the crash continues, it is a pattern misuse. If it does not happen, continue to lower the target iOS release to 15.0 and run the project. If it doesn't crash, step down to iOS 14 and run the project until the crash occurs.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’23
Reply to Closure containing a declaration cannot be used with result builder 'ViewBuilder
Do not nest Content_Preview nor WebView into ContentView. // //  ContentView.swift // import SwiftUI import WebKit import UIKit // ** DO NOT NEST ** struct ContentView_Previews: PreviewProvider {     static var previews: some View {         ContentView()     } } struct ContentView: View {     let webView = WebView(request: URLRequest(url: URL(string: "https://www.apple.com")!))     var body: some View {         VStack {             webView             HStack {                 Button(action: {                     self.webView.goBack()                 }) {                     Image(systemName: "arrowshape.left")                         .font(.title)                         .foregroundColor(.blue)                         .padding()                 }                 Spacer()                 Button(action: {                     self.webView.goHome()                 }) {                     Image(systemName: "house.fill")                         .font(.title)                         .foregroundColor(.blue)                         .padding()                 }                 Spacer()                 Button(action: {                     self.webView.goForward()                 }) {                     Image(systemName: "arrowshape.right")                         .font(.title)                         .foregroundColor(.blue)                         .padding()                 }             }         }     } } // ** DO NOT NEST ** struct WebView: UIViewRepresentable {     let request: URLRequest     private var webView: WKWebView?     init (request: URLRequest) {         self.webView = WKWebView()         self.request = request     }     func makeUIView(context: Context) -> WKWebView {         return webView!     }     func updateUIView(_ uiView: WKWebView, context: Context) {         uiView.load(request)     }     func goBack() {         webView?.goBack()     }     func goForward() {         webView?.goForward()     }     func goHome() {         webView?.load(request)     } }
Replies
Boosts
Views
Activity
Feb ’23
Reply to Within 24 hours of release my app is number one board game on Mac App Store, however, analytics are opposite
Give it some time, after the welcome party is over it will settle into its actual spot after the curiosity is over. It's also too early for any analytics.
Replies
Boosts
Views
Activity
Feb ’23
Reply to Swift 5.7 compiler doesn't check API availability of PropertyWrapper
Report this here: http://bugreport.apple.com/
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’23
Reply to Fatal error: No ObservableObject of type TrimmedContext found. A View.environmentObject(_:) for TrimmedContext may be missing as an ancestor of this view.
You cannot use @EnvironmentObject var context: TrimmedContext outside of a View. Remove @EnvironmentObject from the property wrapper. Change  @StateObject in TrimmedView to @EnvironmentObject
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’23
Reply to Fatal error: No ObservableObject of type TrimmedContext found. A View.environmentObject(_:) for TrimmedContext may be missing as an ancestor of this view.
You cannot use @EnvironmentObject var context: TrimmedContext outside of a View. Remove @EnvironmentObject from the property wrapper. Change  @StateObject in TrimmedView to @EnvironmentObject
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’23
Reply to ViewBuilder does not force View update
objectToUse and nameToUse of MyView should be a Bindable<Object> and Bindable<String> parameters to a pair of matching local variables, so when a data change occurs, it will trigger a UI update. You should also use return in each case.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’23
Reply to How to populate a pixel buffer much faster?
Right now, you're running in O(n^2), and as your screen size gets larger, 1080p vs 2K vs 4k vs 8k, the lengthier your runtime becomes. Moving this to Metal or OpenGL will be the better option since GPUs are faster than CPUs. Explore changing from for loops to something recursive. The BGRAPallet and the pixel buffer ptr should also be the same size, or the first N BGRAPallets are processed, then you're left just updating the position 0 of pixalBufferPtr for another million plus cycles.
Topic: Programming Languages SubTopic: Swift Tags:
Replies
Boosts
Views
Activity
Jan ’23
Reply to Apple Weather app vs Weather Pro from Luni - copycat ?
How else do you propose Weather Apps present the information? How else do you propose Wendys and Mac Donalds make their burgers? And for the records, the Apple Weather App doesn't use a tab bar controller. Something tells me you're an ex-disgruntled employee of Luni. How else would you have known to point out something like this? It looks pretty petty on your part.
Replies
Boosts
Views
Activity
Jan ’23
Reply to Is it possible to route specific DNS requests to the local DNS server with custom NEDNSSettingsManager configuration?
Purchase an MDM solution if you want to manage the settings for corporate devices; what you're asking to do is most likely on an App level and not a device level using the APIs mentioned for apparent privacy and security reasons.
Replies
Boosts
Views
Activity
Jan ’23
Reply to How do you report TestFlight apps that break the rules
If the app is not yours, it's none of your concern how the owner opts to beta test their application.
Replies
Boosts
Views
Activity
Jan ’23
Reply to How do I report a testflight app to Apple?
Is the application yours?
Replies
Boosts
Views
Activity
Jan ’23