Question

I have a swift project and hav3 an Activity Indicator declared in my ViewController. When I click a UIButton, the indicator starts. However, I can not access this indicator in my other class to stop it when the code is completed. Any help would be appreciated.

@IBOutlet var spinner: UIActivityIndicatorView! // <--- want to access in another class
@IBAction func sendClick(sender: UIButton) {
    spinner.startAnimating()
    var msg = Message()
    msg.send()
}
Was it helpful?

Solution

Take a look at your scopes and access control!

If the two classes are not within the same module, you need to declare the object as public. If the object is even declared to be private, you can't access it from another file's class.

For more information about access control read this article from Apple's swift blog: https://developer.apple.com/swift/blog/?id=5

or here in the documentation: https://developer.apple.com/library/prerelease/mac/documentation/Swift/Conceptual/Swift_Programming_Language/AccessControl.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top