I am trying to get an array from AppDelegate in my ViewController, every time I try to connect to Xcode, it only allows me to access ViewController values, not AppDelegate.
in the following code, I can use two different methods, I show both of them.
- I can just bind combobox to serialpPortManager.availablePorts array
- I can grab the array and insert it into another array so the ViewController sees the array from AppDelegate and then binds the array to combobox
I would like to do this in the first way, but cannot connect it to Xcode.
Appdelegate.h
@interface AppDelegate : NSObject{}
@property (nonatomic, strong) ORSSerialPortManager *serialPortManager;
@property(nonatomic, retain) NSArray *availPorts;
AppDelegate.m
self.serialPortManager = [ORSSerialPortManager sharedSerialPortManager];
ORSSerialPortManager *portManager = [ORSSerialPortManager sharedSerialPortManager];
availPorts = portManager.availablePorts;
ViewController.m
AppDelegate *appDelegate = (AppDelegate*)[[NSApplication sharedApplication]delegate];
NSString * result = [appDelegate.availPorts description];
combobox appDelegate, , ViewController? Xcode, appDelegate?