Post

Replies

Boosts

Views

Activity

Comment on How to store one line of code from class into a button action?
I know my problem already but I dont know how to fix it. How do i call my function that is in final class -> init() ?? I tried calling empty functions outside of init() on button action and it works, only func within the init() is not recognise? How do I globalize the function that is in the init(). The whole socket set up is in the init(). Therefore, i cant pull the func out of init() as it will cause error.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’21
Comment on How to store one line of code from class into a button action?
Hi, Yes, its the receiving part from server code. I am able to receive from server so i did not show it here. Currently, From Swiftui, I can receive continuously from JSON (Server) side and can only send the message once from SwiftUI to JSON when the network is connected. Im stuck at the part where whenever I click the button on swiftui, it will send a fixed msg. Continuous. I created the function in the final class but when i write it in the button`s (action: sendMsg), the xcode says "Cannot find 'sendMsg' in scope'. I tried creating the send function outside of the class and I got a lot of error. I am new to Xcode. How do I create the function globally? So that the content view will recognise my function that is in the final class init?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Nov ’21