In my storyboard I define a key value for my viewController as shown:
How can I retrieve the value of this key path in viewDidLoad on Swift 4?
Please read "category" not "catAgory" ;-)
In my storyboard I define a key value for my viewController as shown:
How can I retrieve the value of this key path in viewDidLoad on Swift 4?
Please read "category" not "catAgory" ;-)
I found solution, thank you for your help
class MyViewController: UIViewController {
@objc var category: String = "undefined"
override func viewDidLoad() {
super.viewDidLoad()
print ("cat", category)
}
}
This code print "service" in the console. Don't forget @objc in your property declaration.
You didn't get the point of user defined runtime attributes. These attributes are the properties of an UIKit object defined in interface builder rather than in the code. The thing you wrote is nonsense because you need to set properties which ALREADY are defined by UIKit. For example it is completely okay to write on UIView in defined runtime attributes this:
layer.cornerRadius| Number | 10
because UIView has property layer
, which has property cornerRadius
, you are able to set it to your custom value during runtime...
But to simply answer your question: You cannot, you have to subclass your UIKit Object, add this property to it in code and then you can set this up in user defined runtime attributes AND in your code.
see these links: