Проще говоря, вы не можете иметь два представления, использующих один и тот же URL. Если вам нужна отдельная функциональность, предоставляемая отдельным представлением, определите отдельный URL.
If you declare a static variable in the implementation file of a class, then that variable is only visible to that class.
You could declare the static variable in the header file of the class, however, it will be visible to all classes that #import
the header.
One workaround would be to declare the static variable in the parent class, as you have described, but also create a class method to access the variable:
@implementation ServerParser
static NSString *currentElement;
...
+ (NSString*)currentElement
{
return currentElement;
}
...
@end
Then, you can retrieve the value of the static variable by calling:
[ServerParser currentElement];
Yet the variable won't be visible to other classes unless they use that method.
Обходной путь - объявить статическую переменную в реализации родительского класса И также объявить свойство в родительском классе. Затем в методах доступа обращайтесь к статической переменной. Таким образом, вы можете получить доступ к статическим переменным, таким как свойства с точечным синтаксисом. Все подклассы имеют доступ к одной и той же общей статической переменной.