This is a feature of OOP. Depending on what you want to do you need to do one of two things. Either instantiate the object in both places or instantiate it in one place and pass it to the other. If you want to pass it, you could use something like NSNotification. In the class that is going to use the shared audioPlayer you could do something like:
- (id)init
{
self = [super init];
if (self) {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(incomingAudioPlayer:)
name:@"ShareAudioPlayer"
object:nil];
}
return self;
}
- (void)incomingAudioPlayer:(NSNotification *)notification {
// do stuff here
}
And in the class where you instantiate audioPlayer (just after the instantiation) you could do:
[[NSNotificationCenter defaultCenter] postNotificationName:@"ShareAudioPlayer"
object:self
userInfo:audioPlayer];
Actually you might have to play with userInfo and stick audioPlayer in an NSDictionary or something, but this should get you closer. This is the method I normally use, there may be others.