Unable to access iboutlets when called from other class
I have two classes, and Class1 calls a meth开发者_Python百科od from Class2, like this:
Class2 *c = [[Class2 alloc] init];
[c cMethod];
[c release];
The method get called, but if I try to access an IBOutlet, nothing happens.
self.outlet.text = @"asdf";
However, when I do it from viewDidLoad, it works.
[self c];
You're apparently expecting the instance of Class2 you create above to be somehow mysteriously linked to a previously created instance of Class2 that is bound to an IBOutlet.
Please ask your professor to explain to you how different instances of a class are, indeed, different.
精彩评论