简体   繁体   中英

Access View Controller method from App Delegate in Swift - asking for parameter

I am trying to call a method from my view controller in the app delegate file, and it is asking for a parameter of the type of whatever class I am trying to call. ie: what is happening is that I am trying to call a method from the messages_send_message.swift class / file, and for any method in that file (including the ones without parameters) it wants a parameter of messages_send_message .

what is happening: I am trying to call the update method from the app delegate file when it receives a push notification. So that if they are already in the chat, it just updates/refreshes the feed.

so here is the method: messages_send_message.update() and it is asking for: messages_send_message.update(messages_send_message)

But it throws an error by that parameter when I try to use it. I also tried putting the () after the messages_send_message parameter, but same issue, still get the errors.

Anyone know a fix?

By the way, the error is: Missing argument for parameter #q in call

If your update doesn't reference self, then make it a class method and that will fix your problem.

If the method does reference self, then you need an instance of the class to call the method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM