是否有“stringByReplacingCharactersInRange” Monotouch中NSString的方法?
在 Apple 文档中 NSString< /a> 有一个 stringByReplacingCharactersInRange 方法,但是我在 Monotouch 中找不到这个方法。
Monotouch - 本机 API 绑定中是否缺少此方法实现?
我需要这个方法来实现 shouldChangeCharactersInRange 内的一些自定义字符串处理逻辑
In Apple documentation for NSString there is a stringByReplacingCharactersInRange method, however I cannot find this method in Monotouch.
Is this method implementation missing from Monotouch - native API binding?
I need this method to implement some custom string handling logic inside shouldChangeCharactersInRange
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这里有一些代码可以完成您需要的操作:
Here's some code to do what you need:
并非所有内容都绑定到
NSString
,因为它大部分会复制System.String
中可用的 .NET 方法。最简单的方法是处理 .NET(本机)字符串,并在您需要与需要它的 API 进行互操作时从中创建一个
NSString
。这样做的优点是最大限度地减少托管/非托管转换的数量(成本很小)。如果您从 API 收到
NSString
,将其转换为字符串然后对其进行操作,情况也是如此。如果您发现没有类似 .NET 方法的特定绑定,请在 http://bugzilla.xamarin.com 上填写错误报告 我们将确保将其包含在 MonoTouch 的未来版本中。通常可以立即提供解决方法来解锁您。
Not everything is binded for
NSString
because it would mostly duplicate the .NET methods available inSystem.String
.The easiest way is to work on .NET (native) string and create an
NSString
from them if/when you need to interoperate with API that requires it. This has the advantages of minimizing the number of managed/unmanaged transitions (there's a small cost to that).Same goes if you receive a
NSString
from the API, convert it into a string then manipulate it.If you find a specific binding that has no similar .NET method then please fill a bug report on http://bugzilla.xamarin.com and we'll make sure to include it in future releases of MonoTouch. Often an immediate workaround can be given to unblock you.