ios - Calling a class method in another viewController -


this question has answer here:

i have class following

class viewcontrolelr: uiviewcontroller {     func instantiatedocumentsubpartnavigationvc(documentpart: documentpart, documentpartsarray: [documentpart]) { //definition } } 

in other class called viewcontroller2, wanna call above method. expect see below can pass parameters method in viewcontroller2

viewcontroller.instantiatedocumentsubpartnavigationvc(documentpart: documentpart, documentpartsarray: [documentpart]) 

but see is

viewcontroller.instantiatedocumentsubpartnavigationvc(viewcontroller) 

how can utilize class method in different class?

functions can declared operate @ 1 of 2 levels - class or instance. when call function, have match correctly.

currently code has viewcontroller.instantiatedocumentsubpartnavigationvc, , viewcontroller class, not instance of class. not match function, declared operate on instance (since doesn't have keyword class or static).

so either need use instance of viewcontroller (which might viewcontroller little 'l'), or declare function class. choice depends on you're trying do, it's first option.

this why question got marked duplicate - because looks want call 1 class-level function class-level function, suspect that's not you're after.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -