Compilation fix for latest versions of Xcode, extract duplicated code and use iOS-style function for accessing shared service..