Hi everyone,
I've been cracking my head on a prob that doesn't quite make sense. Say I have the following in my project:
AppDelegate MyClassA MyClassB MyViewController
In MyClassA, there is a property of type MyClassB by the name classB. MyClassB has a property of type NSMutableArray by the pointer name myArray.
When in the MyViewController under viewDidLoad I instantiate MyClassA to access the myArray in its(MyClassA's) MyClassB property such as follows:
MyClassA *classA = [[MyClassA alloc] init];
NSLog([NSString stringWithFormat:@"%i", [[[classA classB] myArray] count]);
It will display the count on the log successfully and at the same time, further access to the contents of the array works fine.
However, still in the MyViewController, when the MyClassA is instantiated and accessed from the delegate as follows:
AppDelegate *aDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
NSLog([NSString stringWithFormat:@"%i", [[[aDelegate classA] classB] myArray] count]]);
the log will still display the count successfully, but further access to the contents in the array fails showing no error but a "Current language: auto currently objective-c" -- just one line of it.
This is a strange behavior I can't figure. Is there a difference between accessing objects instantiated in the delegate and accessing objects locally in a function(in the viewDidLoad of ViewController as in the example) or something?
Help is very much appreciated =D