Post

Replies

Boosts

Views

Activity

Reply to Run something before another thing
I figured out that for my case, I can just call it and then wait 0.6 seconds and call it again. To wait blank seconds use (replace 0.6 with the wanted amount):  That's a super bad idea. When communication is unstable, asynchronous call may take minutes. Do you want to replace 0.6 with 120?
Topic: UI Frameworks SubTopic: UIKit Tags:
Mar ’21
Reply to Run something before another thing
What will 120 do? As I wrote, When communication is unstable, asynchronous call may take minutes. I am sure you have tested your super bad idea only on a usual communication status. There are many chances a simple communication would take tens of seconds. But you have no need to wait hours. If the communication was too bad and took more than two minutes, it might end with timeout error.  here is the function header: Thanks for showing the code. A little more, can you show the whole method including the call to setRandomJoke()?
Topic: UI Frameworks SubTopic: UIKit Tags:
Mar ’21
Reply to Run something before another thing
Here you go: Thanks. But as far as I checked, there are no significant difference than the example code I have shown. Can you show viewDidLoad() and viewWillAppear(_:)?  I don't know what they do or how to use them. Better learn it. Xcode Help page is really helpful. Add breakpoints to your code - https://help.apple.com/xcode/mac/current/#/dev9a374afc9.
Topic: UI Frameworks SubTopic: UIKit Tags:
Mar ’21
Reply to Run something before another thing
Yes here you go: Thanks for showing your code. But your viewDidLoad() and viewWillAppear(_:) are modified from what I have shown, breaking the basic principle: Do the next thing inside the completion handler. If you have done any changes breaking this principle, your code would never work as expected. Or do you still not understand what completion handler means?  I have not had the time to figure out what's wrong using breakpoints. I guess you just need time to learn it, or your Xcode is broken. Pleas tell me when you fix the issue and are ready to use breakpoints. One more, did you yourself write the code you have shown to me? The replies from you makes me feel as if you do not understand any parts of your code.
Topic: UI Frameworks SubTopic: UIKit Tags:
Mar ’21
Reply to Run something before another thing
I want you to understand that I am still really learning. No problem. Everyone is learning something everyday. One thing I want you to understand is you have no need to pretend you knew everything. You can ask when you find some terms you do not know. You just need to clarify what you do not know.
Topic: UI Frameworks SubTopic: UIKit Tags:
Mar ’21
Reply to Notification Center Help
My common ancestor VC is connected to my HdVC through a segue and my FaVC through a bar button item and is held by a container nav controller.  Thanks for trying. So, something like this? container nav controller | common ancestor VC ---------- HdVC ---------------- FaVC segue bar button item
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’21
Reply to How to get single object JSON API in SwiftUI
I need to edit it to be for a single object.  Sorry, I have been missing your words my old code the gets a multi-object array. But you just need to pass the struct type to decode(_:from:) instead of Array type: For example: struct SingleObject: Codable { var sunRise: String //... } enum ApiError: Error { case dataIsNil } class ApiCall { func getSingleObject(completion:@escaping (ResultSingleObject, Error) - ()) { guard let url = URL(string: "...") else { return } URLSession.shared.dataTask(with: url) { (data, _, error) in if let error = error { print(error) completion(.failure(error)) return } guard let data = data else { print("data is nil") completion(.failure(ApiError.dataIsNil)) return } do { let singleObject = try JSONDecoder().decode(SingleObject.self, from: data) //- print(singleObject) DispatchQueue.main.async { completion(.success(singleObject)) } } catch { print(error) completion(.failure(error)) } } .resume() } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21
Reply to Mac OS version outdated for WWDC 2021 challenge
The Swift Student Challenge page - https://developer.apple.com/wwdc21/swift-student-challenge/ clearly states this as a requirement: Your Swift playground must be built with and run on Swift Playgrounds 3.4.1 on iPadOS 14.4.2, Swift Playgrounds 3.4.1 on macOS 11.2.3, or Xcode 12.4 on macOS 11.2.3. If it runs on iPadOS, it must be optimized to display properly on all models of iPad Pro. I think you can develop the Swift Playground using your Mac and borrow a Mac of your friends when building the app and submitting it to Apple.
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’21
Reply to Integrate Metal/ObjC Tutorial into SwiftUI
This what I have done: import SwiftUI import MetalKit struct MyMtkView: UIViewRepresentable { typealias UIViewType = MTKView var mtkView: MTKView init() { self.mtkView = MTKView() } func makeCoordinator() - Coordinator { Coordinator(self, mtkView: mtkView) } func makeUIView(context: UIViewRepresentableContextMyMtkView) - MTKView { mtkView.delegate = context.coordinator mtkView.isPaused = false mtkView.preferredFramesPerSecond = 60 mtkView.enableSetNeedsDisplay = false mtkView.framebufferOnly = true return mtkView } func updateUIView(_ uiView: MTKView, context: UIViewRepresentableContextMyMtkView) { // } class Coordinator : AAPLRenderer { var parent: MyMtkView init(_ parent: MyMtkView, mtkView: MTKView) { self.parent = parent guard let metalDevice = MTLCreateSystemDefaultDevice() else { fatalError("Metal is not supported on this device") } mtkView.device = metalDevice super.init(metalKitView: mtkView) mtkView.framebufferOnly = false mtkView.clearColor = MTLClearColor(red: 0, green: 0, blue: 0, alpha: 0) mtkView.drawableSize = mtkView.frame.size mtkView.enableSetNeedsDisplay = true self.mtkView(mtkView, drawableSizeWillChange: mtkView.drawableSize) } } } You need to create a device using MTLCreateSystemDefaultDevice as in the thread you have shown You need to initialize AAPLRenderer (Rendere?) with passing mtkView
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’21