I've tried the various suggestions from other posts and still can't seem to get this working properly.
Here is my workflow.
AppDelegate.m
#import CustomObject.h // cocoaAsyncSocket wrapper with delegates
- create customObject[[alloc] init];
mainViewController.m
- (IBAction)connectDisconnect
{
// Access our custom object inside the TPAppDelegate class object.
TPAppDelegate *appDelegate = (TPAppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.customObject connectToIP:host port:port timeout:10.0];
customObject.m
#import mainViewController.h
// custom object delegate
- (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag
{
// Access methods and properties inside 'mainViewController' class object.
mainViewController *mainView = (mainViewController *)[UIApplication sharedApplication];
// call method
[mainView textViewLog:@"Hello"];
.
.
}
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIApplication textViewLog:]: unrecognized selector sent to instance 0x188750'
The goal is to get my customObject call a method in the mainViewController.
What am I missing? Or am I going about it completely wrong?