访问另一个类中的一个类的数据variables

在任何人提出有关xxxx问题的类似或重复问题之前,我已经检查了27个问题,至今没有人能够明确和帮助我,最有可能的是没有人以最简单的forms发布这个问题。

所以我有一个在我存储一些数据的1类NSstring。

##Class 1 .h @property ..... NSString *str; .m -(void) someMethod { self.str = @"Blah blah"; } 

现在我想通过类2中的属性“str”访问这个“Blah Blah”数据,而不通过任何方法或类似的方法传递它。 我只是需要访问它的地方(例如让我们说viewDidLoad)。 什么是最简单的方法?

PS:我正在考虑在appdelagate.m中创build一个* tempStringvariables,并通过创build一个AppleDelegate * apdg对象并访问它来在w / e类中访问它。 任何其他的想法?

SecondViewController.h

 @property (nonatomic, copy) NSString *textblah; 

FirstViewController.m

 #import "SecondViewController.h" // where you want to store value SecondCiewController *secondViewController = [[SecondViewController alloc] init]; secondViewController.textblah = stringToStore; // and [self.navigationController push:secondViewController animated:YES]; // You can log the set value with to check whether it was successful or not. NSLog(@"textblah: %@", textblah); 

为了完整的理解代码和过程,你可以看这个和这个video教程

你会发现他们的信息和易于理解的特别初学者。