Can two view managers be delegates for each other?

I am studying objective-c and cocoa touch simultaneously with the creation of the application, so I have a pretty simple question (I think), sorry, I do not have enough points on the website to show a visual diagram of my site.

But let me explain, I have the following

  • Main viewcontroller
  • ViewController A
  • ViewController B
  • ViewController C
  • ViewController 1
  • ViewController 2

ViewController A, B, and C have protocol delegates that are used by the Main ViewController.
ViewController 1 and 2 have protocol delegates that are used by ViewController C.

However, I also need the ViewController C to be a delegate for the Main ViewController.

Because of this, I recently created a protocol delegate in the Main ViewController, however when I try to designate ViewController C as a delegate, I get errors, especially when you try to import the Main ViewController header file into the View Controller C I'm getting a failed compilation message for the following reasons.

  • The main ViewControllers header file may no longer find the protocol for ViewController C
  • Expected list of qualifiers before "ViewController C"

Am I trying to do what I'm trying to do? Can two view controllers bd delegate to each other? And if not what would be the idea to achieve what I am doing?

ViewController CI , Main ViewController, , ViewController B ( , ), ViewControler B view , , , ( , , , ).

, -

+3
3

. , - :

@protocol SomeDelegate;

@interface FooThatUsesSomeDelegate : NSObject {
    id<SomeDelegate> delegate_;
}
@end

SomeDelegate, , . , .

. .

+1

, ( St3fan), , .

+1

ARC :

@property(weak)id<MyDelegateProtocol> *delegate;

, , .

0

Source: https://habr.com/ru/post/1730686/


All Articles