English 中文(简体)
如何从 nstring 中删除 " 字符的出现?
原标题:How to remove the occurence of " characters from nsstring?

我熟悉如何删除不需要的查拉特人, 如 < code_ } }, & lt;, & gt;, , but I cannot to find how remove agency of "( 颠倒的逗号), 在 < strong > NSString < / strange > 中, 我无法找到如何消除 " (倒置的逗号) 的出现。 任何有关此建议都会很有帮助 。 谢谢 。

最佳回答

倒转逗号是 客观 c 和其他许多语言中的预留字符。 所以您必须避开它们。 在目标 c (和许多其他语言) 中, 特殊保留字符被排除, 等待字符的反斜线 < code_ /code> 。

所以,如果你有这样一条绳子:

fsdfads"dsfdsa

它可以即时逃离特殊的字符, 颠倒的逗号,像这样:

NSString* s = @"fsdfads"dsfdsa";

您可以删除反转逗号正在做的 :

[s stringByReplacingOccurrencesOfString:@""" withString:@""];

希望这有帮助!

编辑:

您评论说您有一个类似@ "108" 的字符串, 您想要获得 108 的字符串。 如果您想要它作为NSString, 您应该按我所发的做。 如果您想要108 个NSN 数字, 您应该将其从NSSting 转换为NSN 数字 。 请使用 < code> NSN Indition :

NSNumberFormatter * f = [[NSNumberFormatter alloc] init];
[f setNumberStyle:NSNumberFormatterDecimalStyle];
NSNumber * myNumber = [f numberFromString:@"108"];
[f release];   // If you are not using ARC
问题回答

你可以这样做:

NSString *strText = @"abcdef""xyz";
[strText stringByReplacingOccurrencesOfString:@""" withString:@""];

如果您在谈论引号,请使用以下文字:

[yourString stringByReplacingOccurrencesOfString:@""" withString:@""];

如果您在谈论别的东西, 仍尝试使用该字符之前的逃跑字符( 设置 < code_ / code > ) 。

希望有帮助





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签