Hi,
I'm fairly new so I'm still trying to figure out the nuances of objective C that I might have missed. Correct me if I'm wrong?
I noticed this about referenced objects
Given this, when 'callMethod' is call from inside class A, it will print "Andy, Eric, Aaron"...
When called from class B, it will print 'null'. This is what I'm seeing on a regular basis. The only way I've been able to resolve this is to create a protocol/delegate so calling from class B won't print out a 'null'
Am I correct in the observation?
I'm fairly new so I'm still trying to figure out the nuances of objective C that I might have missed. Correct me if I'm wrong?
I noticed this about referenced objects
Code:
//class A
@interface A {
NSArray *myArray;
}
- (void)callMethod;
@end
@implementation
//init sets up a uinavigation
-(void)init {
myArray=[[NSArray alloc] initWithObjects:@"Andy", @"Erik", @"Aaron", nil];
[self.callMethod];
}
-(void)callMethod {
NSlog(@"data %@", myArray);
}
@end
//class B
@interface B {
- (void)callMethodFromA;
}
@end
@implementation
- (void)callMethodFromA {
A *call = [[A alloc] init];
[call callMethod];
[call release];
}
@end
Given this, when 'callMethod' is call from inside class A, it will print "Andy, Eric, Aaron"...
When called from class B, it will print 'null'. This is what I'm seeing on a regular basis. The only way I've been able to resolve this is to create a protocol/delegate so calling from class B won't print out a 'null'
Am I correct in the observation?