The easiest way for me to explain this is to upload a test app, so I’ve stripped out everything that is unecessary and uploaded a bare bones project to SendSpace.
http://www.sendspace.com/file/z86g0z
I’m writing an app that will receive custom URL’s from Mobile safari like “plasma://hello-world”. These are then processed by my app and it displays a notification on screen.
In the test app the main class is a singleton and there is a “test” button this demonstrates what should happen when you open it via a URL. You get the custom link shown in a label on the screen and a green notification label at the top which then fades away. During this process the Xcode console shows this …..
2012-09-05 21:53:29.719 PlasmaLinker[2866:f803] Link: plasma:Test+Link
2012-09-05 21:53:29.778 PlasmaLinker[2866:f803] Show Alert: Success - Link Received
2012-09-05 21:53:35.779 PlasmaLinker[2866:f803] Remove Alert
All works fine.
Now I launch it from Mobile Safari by entering “plasma://hello-world” I hit enter and Safari switches to my app, the console shows EXACTLY the same output (with what ever URL you launch it with), however I get nothing in the UI at all. The link isn’t placed in the text box, the notification is never shown.
What am I doing wrong? After its been launched with the URL you can again click the test button and see the UI elements change as desired. Its driving me nuts but I don’t know enough to be able to get it to work when launched by a URL. Can someone please shed some light on this?
Kind Regards
Plasma
Your singleton method that gets the
PlasmaLinker_ViewControlleris returning a different instance to the one that is created by the storyboard and added to the main window.One example that works, (in your app delegate)
Another option is to override the view controller’s
-(id)initWithCoder:(NSCoder *)decoderand set your shared instance toselfin that method.