Based on my reading around, I have learned that I need to set a variable in my AppDelegate that references my view controller so that I can do things like this. Receive a barcode scan and subsequently call a method in a controller and pass in that barcode scan. So I have this in my AppDelegate.
- (void)BarcodeDataArrived:(char *)BarcodeData;
{
[myViewController LoadBarcodePage:BarcodeData];
}
I know that this method is being called when my bluetooth scanner scans a barcode. The problem is that myViewController object is not referencing the current view controller and as a result all the objects are null.
I don’t think I want to create a new instance of myViewController since the storyboard is already creating an instance of it when the app loads. I just want to be able to reference the same object that the storyboard is creating. So, if I am understanding things correctly, I need to do something like this in my AppDelegate to set the variable:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
// I Want To Set A Reference To My View Controller Here Such As...
myViewController = aViewController;
// Where aViewController Is What The Storyboard Initialized.
return YES;
}
How would I do this. All the references I have found on the NET seem to involve nibs and not storyboards.
This is my first app. Help please!
You shouldn’t implement that in your App Delegate.
Why don’t you try to implement your BarcodeDataArrived in a ViewController then
Then in the prepareForSegueMethod you can send data to the destination Controller
Now if you don’t want to change the view then you have to try another approach, myViewController should be an object ( or class) and implement the method LoadBarcodePage in there. You could have the object in the delegate and it can be referenced in any class by using