ios - Avoid hard coding storyboard IDs in 2 places -


When I want to set an ID for a view controller, I go into the storyboard file, select View Controller , Then type something like "theVCID" in Inspector I Storyboard ID on Identity:

When I want to use that view controller in code then I do something like this:

  UIViewController * myVC = [MyStoryboard instantiateViewControllerWi ThIdentifier: @ "theVCID"];  

Is there any way to hardcode this id string at a place instead of hard coding inside the storyboard and when I use it in the code?

If I get a variable in the Storyboard XML, I could get the hardcode string variable in the XML source, but I do not know how to set a variable so that the storyboard XML could access it.

should be based on the assumption of the description of an implementation. Technically, storyboards can change their data type in the future, and it will break your implementation.

The safest way to do this is to put your storyboard identifiers in a single class (say storyboard coordination controller) and simply reference storyboard objects through this single interface, hope you never get into such a situation Should be where these values ​​are changing often, and if you definitely want to do something about it):


Comments