Вопрос

I am a beginner in Ios developement and I'm developping a tabed application but I would like a property accessible from each view so i write this in appDelegate: @property (strong, nonatomic) NSString *test; But now I don't know how to access this string from my firstViewController.m and secondViewController.m

Это было полезно?

Решение

You need to create Object of Appdelegate class like:-

AppDelegate *del = [[UIApplication sharedApplication]delegate];

and used this defined string in any class using del.test. Do not forget to import your Appdelegate class in to particular class that you want to use it's string. And also @synthesize your string in .m appdelegate class as well.

UPDATE:-

If you wish to use Appdelegate Object in particular class then Import App-delegate in to .h file like:-

enter image description here

and .m class in ViewDidLoad

enter image description here

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top