I have a tabbed views where I need to select various options from different tabbed views which should be appended in the same string. For this I want to use a NSMutableString.
After all the options are selected and string is formed as required. I want to access this NSMutableString in the next view which is not tabbed. I think for this I need to declare the NSMutableString as a global variable?
Can someone please help me with this. I am new to objective-c and xcode. Thank you. Any help is much appreciated!
Another option would be to have a singleton object, especially useful if you have more than just one variable you want shared.
Here’s a good post about doing singletons right: http://lukeredpath.co.uk/blog/a-note-on-objective-c-singletons.html
Basically you’d have write a very simple class something like:
State.h:
State.m:
and then whenever you need it you could do:
Even simpler you can use singleton macro from here: https://gist.github.com/1057420#gistcomment-63896
I’ve personally found this pattern to be extremely useful.