I am new to osx and xamarin development. I have developed an application to do some stuff on a given folder using Xamarin.Mac in C#. I added this application to right-click menu of folders in Finder using Automator Service. How can I pass the name of the right-clicked folder to Xamarin application? If this is not possible how to add a file / folder browse button to my application in XCode? Thanks in advance
Asked
Active
Viewed 199 times
1 Answers
0
In Automator you can use a "Run Shell Script" action and open the XamMac application with arguments like you would if you were manually launching it via the cmd line.
This would be a "Run Shell Script" as an "Automator Service":
for f in "$@"
do
myArgs+="\""${f}"\""" "
done
echo "${myArgs}"
/Applications/XamMacStartupArgs.app/Contents/MacOS/XamMacStartupArgs "${myArgs}" &
In your XamMac application, Main will receive those args passed in, you of course would actually do something with them:
static class MainClass
{
static void Main (string[] args)
{
Console.WriteLine (args[0]);
NSApplication.Init ();
NSApplication.Main (args);
}
}
NOTE: If you need to pass "arguments" to a running XamMac app, you would need to hook the open and reopen Apple event handlers and handle them that way instead:

SushiHangover
- 73,120
- 10
- 106
- 165
-
Thanks very much, I will try this – Asela Aug 06 '15 at 04:48