I think this is more than 1 question but I don't see why threads should be limited.
First off, can a Protocol be used without a Delegate ?
So from example, if I have a ...
ViewController that inherits "doThisProtocolDelegate" {
and conforms to variables / functions,
also has an instance of WhateverClass.
}
then the instanced WhateverClass {
that has "thisDelegate: doThisProtocolDelegate"
then some function using "thisDelegate.(var/func)"
}
Which is suppose to pass to the ViewController (the parent) because it has inherited the Protocol, only by setting in ViewController "WhateverClass.thisDelegate = self". A question here is, can the Delegate be set to something other than self ? Also is it possible to do this without an instance of a sub Class within the main Class ?
This might clear a bit up, for example ...
ViewController {
that has an instance of a CustomView
and AnotherViewController
}
CustomView {
has "thisDelegate: doThisProtocolDelegate"
etc.
}
AnotherViewController inherits the Protocol {
conforming ...
}
So getting CustomView & AnotherViewController to talk via the Protocol ? Also where to set the Delegate ?
Another way of doing this without a Protocol is to have a Parent reference. So AnotherViewController has a variable "parent_VC" which exposes ViewController's variables & functions, also one in CustomView then just pass things along via their parent. I got the method from using Unreal Engine and not sure if it's exactly the same, also if there is a reason to not do this hence why people use a Protocol ?