【发布时间】:2014-02-12 00:20:34
【问题描述】:
如何在 iOS 设备中获取当前活动的 iCloud 帐户用户名以在我的应用程序中显示?
OP 下方评论中的代码
NSURL ubiq = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil];
if (ubiq)
{
NSLog(@"iCloud access at %@", ubiq.user); // TODO: Load document...
}
else
{
UIAlertView alert=[[UIAlertView alloc]initWithTitle:@"No iCloud access" message:@"Please set your iCloud account in Setting-iCloud" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; // [alert show]; NSLog(@"No iCloud access");
}
如果您知道如何显示 iCloud 帐户用户名,请告诉我。我已经搜索过这个,但我找不到任何适合我的案例的答案。
【问题讨论】:
-
欢迎来到stackoverflow。这不是 Show me da codez!!! 网站。所以有些努力。如果有,请发布一些代码。
-
我不知道代码...我已经在 google 中搜索过这个但没有解决方案...
-
我使用它的唯一代码是使用此代码:NSURL ubiq = [[NSFileManager defaultManager] URLForUbiquityContainerIdentifier:nil]; if (ubiq) { NSLog(@"iCloud 访问 %@", ubiq.user); // TODO: Load document... } else { UIAlertView alert=[[UIAlertView alloc]initWithTitle:@"No iCloud access" message:@"Please set your iCloud account in Setting-iCloud" delegate:nil cancelButtonTitle :@"OK" otherButtonTitles:nil, nil]; // [警报显示]; NSLog(@"没有 iCloud 访问权限"); } 但它返回 nil..
-
您可以编辑您的原始问题并在其中添加您的代码,而不是在 cmets 中发布代码。
-
感谢 devraj .....编辑我的问题...这是我第一次在 stackoverflow 中发布问题...