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 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 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