I know how delegates work, and I know how I can use them.
But how do I create them?
Answer is actually answered, but I would like to give you a "cheat sheet" for creating a delegate:
DELEGATE SCRIPT
CLASS A - Where delegate is calling function
@protocol <#Protocol Name#>
-(void)delegateMethod;
@end
@interface <#Some ViewController#> : <#UIViewController#>
@property (nonatomic, assign) id <<#Protocol Name#>> delegate;
@end
@implementation <#Some ViewController#>
-(void)someMethod {
[self.delegate methodName];
}
@end
CLASS B - Where delegate is called
@interface <#Other ViewController#> (<#Delegate Name#>) {}
@end
@implementation <#Other ViewController#>
-(void)otherMethod {
CLASSA *classA = [[CLASSA alloc] init];
[classA setDelegate:self];
}
-delegateMethod() {
}
@end