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