Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 获取或模拟当前用户的NSLocale_Ios_Objective C - Fatal编程技术网

Ios 获取或模拟当前用户的NSLocale

Ios 获取或模拟当前用户的NSLocale,ios,objective-c,Ios,Objective C,我希望我的应用程序能在几个iTunes商店中使用。我读了,他们在谈论“当前用户”。那么,谁是“当前用户”?是下载应用程序的用户吗 1) 是否可以根据下载我的应用程序的当前appleID国家/地区或iTunes商店国家/地区获取NSLocale 2) 可以模拟NSLocale来测试我的应用程序吗?在iOS中,没有“当前用户”这样的东西。NSLocale文档中对“当前用户”的引用可能是OSX文档的保留 在iOS中,运行设置应用程序,进入常规,然后进入国际。“区域格式”和“语言”设置定义了您在iOS中

我希望我的应用程序能在几个iTunes商店中使用。我读了,他们在谈论“当前用户”。那么,谁是“当前用户”?是下载应用程序的用户吗

1) 是否可以根据下载我的应用程序的当前appleID国家/地区或iTunes商店国家/地区获取NSLocale


2) 可以模拟NSLocale来测试我的应用程序吗?

在iOS中,没有“当前用户”这样的东西。
NSLocale
文档中对“当前用户”的引用可能是OSX文档的保留

在iOS中,运行设置应用程序,进入常规,然后进入国际。“区域格式”和“语言”设置定义了您在iOS中为
[NSLocale currentLocale]
返回的内容

在iOS中,第三方应用程序无法获取任何种类的appleID或有关特定iTunes商店的信息

要直接回答您的两个问题:

1) 不,您无权访问此信息


2) 是,运行设置应用程序并更改语言和/或区域格式设置。这将影响你在应用程序中获得的
NSLocale

伙计们,我找到了一个获取用户(苹果ID,iTunes商店)区域设置的解决方案!您可以从SKProduct获取区域设置

if([SKPaymentQueue canMakePayments])
{
   [self requestProductData];
}

#pragma mark -
#pragma mark In-App Purchase Delegate Methods

- (void)requestProductData
{
    NSLog(@"IN-APP:requestProductData");
    SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:[NSSet setWithObject:<your in-app identifier>]];
    request.delegate = self;
    [request start];
}

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
    NSArray *myProduct = [[NSArray alloc]initWithArray:response.products];
    if ([myProduct count]>0)
    {
        SKProduct *product = [myProduct objectAtIndex:0];
        NSLog(@"Price: %.2f",product.price.floatValue);
        NSLog(@"Price Locale: %@",product.priceLocale.localeIdentifier);
        NSLog(@"Product Identifier: %@",product.productIdentifier);
        NSLog(@"IN-APP:array count: %i", [myProduct count]);
        [request autorelease];
    }
    [myProduct release];
    myProduct = nil;
}
if([SKPaymentQueue canMakePayments])
{
[自选产品数据];
}
#布拉格标记-
#应用程序中的pragma标记购买委托方法
-(void)请求产品数据
{
NSLog(@“应用内:requestProductData”);
SKProductsRequest*请求=[[SKProductsRequest alloc]initWithProductIdentifiers:[NSSet setWithObject:];
request.delegate=self;
[请求启动];
}
-(无效)产品请求:(SKProductsRequest*)请求DID接收方响应:(SKProductsResponse*)响应
{
NSArray*myProduct=[[NSArray alloc]initWithArray:response.products];
如果([myProduct count]>0)
{
SKProduct*product=[myProduct objectAtIndex:0];
NSLog(@“价格:%.2f”,产品价格浮动值);
NSLog(@“价格区域设置:%@”,product.priceLocale.localeIdentifier);
NSLog(@“产品标识符:%@”,Product.productIdentifier);
NSLog(@“应用内:数组计数:%i”,[myProduct count]);
[请求自动释放];
}
[我的产品发布];
myProduct=零;
}

如果一个用户从XYZ国家创建了appleID,现在从ABC国家使用它,那该用户怎么办?我想在任何地方获得XYZ国家。iOS不是多用户系统,所以我不理解这个问题。请在你的应用程序中添加一个选项,这样用户就可以显式地设置locale.user,并将appleID绑定到XYZ国家下载的应用程序。我想得到XYZ和locale。是否可以自动获取区域设置?在iOS 7.0模拟器设置中更改区域和语言不会更改[NSLocale currentLocale]的结果-它始终返回国家代码“US”和货币代码“USD”。它在6.1模拟器中工作。非常奇怪,重新启动模拟器没有帮助,但当我切换到6.1并返回到7.0.3时,它现在工作正常。在这一点上,我认为这是一个邪恶的灵魂造成的…:D