Compilation fix for latest versions of Xcode, extract duplicated code an...

...d use iOS-style function for accessing shared service..