Iphone,从 MonoTouch 获取国家列表
是否可以复制此处中的代码在 MonoTouch 中吗?
这是我到目前为止所尝试过的:
foreach(string countryCode in NSLocale.ISOCountryCodes){
// How to convert this objective-c code to c#?
// [[NSLocale currentLocale] displayNameForKey:NSLocaleCountryCode value:countryCode]
}
Is it possible to replicate what the code in here does in MonoTouch?
Here is what I've tried so far:
foreach(string countryCode in NSLocale.ISOCountryCodes){
// How to convert this objective-c code to c#?
// [[NSLocale currentLocale] displayNameForKey:NSLocaleCountryCode value:countryCode]
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
遗憾的是,快速浏览一下就会发现 displayNameForKey:value: 从 MonoTouch(和 MonoMac)绑定中缺失(目前从 4.2.x 开始)。我将考虑实施它,并在完成后更新此条目。
更新:解决缺少的绑定的源代码
适应您的喜好并享受 MonoTouch 的乐趣!
ps 我将更新绑定,以便将其包含在 MonoTouch 未来版本中的更适当 API 中;-)
Sadly a quick look shows that displayNameForKey:value: to be (currently as of 4.2.x) missing from MonoTouch (and MonoMac) bindings. I'll look into implementing it and will update this entry once done.
UPDATE : Source code to work around the missing binding
Adapt to your liking and have fun with MonoTouch!
p.s. I'll update the bindings so it will be included in future releases for MonoTouch in a more proper API ;-)
是的,这当然是可能的。 MonoTouch 将 iOS API 包装在 C# 类中,以便您可以在 C# 中执行在 Objective-C 中可以执行的任何操作。不幸的是,您必须下载试用版才能获取文档。我想代码会是这样的:
Yes, it is certainly possible. MonoTouch wraps the iOS API in C# classes so that you can do anything in C# that you can do in Objective-C. Unfortunately you have to download the trial version to get the documentation. I imagine the code would look something like this: