1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #include "MacHelpers.h"
9 #include "MacStringHelpers.h"
10 #include "nsObjCExceptions.h"
12 #import <Foundation/Foundation.h>
16 nsresult GetSelectedCityInfo(nsAString& aCountryCode) {
17 NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
19 // Can be replaced with [[NSLocale currentLocale] countryCode] once we build
20 // with the 10.12 SDK.
21 id countryCode = [[NSLocale currentLocale] objectForKey:NSLocaleCountryCode];
23 if (![countryCode isKindOfClass:[NSString class]]) {
24 return NS_ERROR_FAILURE;
27 return mozilla::CopyCocoaStringToXPCOMString((NSString*)countryCode, aCountryCode);
29 NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
32 } // namespace Mozilla