Search code examples
iosswiftxcodepodfile

Change the value of a variable inside podfile from viewcontroller


import UIKit
import Foundation

open class podview: UIView {
    open var strk = UIColor.black
    .
    .
}

I have to change the value of "strk" from another view controller. Is it possible to do it.


Solution

  • YES, You can do it. There are two way to do this.

    1. Local Notification (NSNotification)

    NSNotificationCenter addObserver in Swift

    1. Delegatation

    Examples of Delegates in Swift

    1. If you want to Change View controller B Value from View controller A then you can directly access to it.

    For EX ViewcontrollerB.yourVariable = Assign value - From View Controller A

    Please review and understand both concepts.

    Happy Coding..:)