Code:
// Code #1
@interface Alice : NSObject
@end
Bob is a subclass of Alice.
Code:
// Code #2
@interface Bob : Alice
@end
Alice has a method in which a variable named Carol is declared.
Scratch code #1. Replace with:
Code:
// Code #3
@interface Alice : NSObject
-(void) aMethod;
@end
@implementation Alice
-(void) aMethod
{
// declare Carol here
}
@end
In Bob's implementation, the aforementioned method is overridden. I want Bob to be able to access Carol.
Code:
// Code #4
@implementation Bob
-(void) aMethod
{
// access Carol here
}
@end
Considering I can safely modify Alice's files, what is the best way to approach this problem?
It's impossible to say from your description alone.
This is because in code #3, where Carol is declared inside aMethod, there are several different ways of "declaring Carol". In some of them, it's not possible at all to declare Carol in a way that makes it accessible in Bob, except by changing the lifetime of Carol. In others, the lifetime of Carol is fine, but the scope would need to changed to make Carol accessible to Bob. So it depends entirely on exactly what the actual code is that "declares Carol". Since you didn't post code, no one knows the answer.
If you had posted actual example code for Alice, as in code #3, with actual syntactically correct code for the body of aMethod, it would be simple to answer the question. Because then we could see the actual code in question.
As it now stands, I have to post code I wrote using your description, which may or may not accurately reflect what you think the description says. Furthermore, I have no clear idea what your intent is for declaring Carol. Carol could be an automatic variable, it could be a local static variable, it could be an extern variable, it could even be an instance variable. Those are four distinct possibilities, and each one has a different solution.
When you post actual code, we can see what you're talking about.
When you don't, we have to guess what the code is, and hope your description is complete and accurate. When the description is incomplete or inaccurate, the question is unanswerable until you either provide code that's complete and accurate, or someone else provides code that you affirm is accurate.
Finally, none of the code I wrote was difficult, so I don't see why you're incapable of providing it.