简体   繁体   English

从字符串iOS Swift中删除所有qoutes

[英]Remove all qoutes from a string iOS Swift

I've seen solutions for objective-c but not for swift. 我见过针对Objective-C的解决方案,但没有见效。 I'm new to iOS development, any help would greatly be appreciated 我是iOS开发的新手,将不胜感激任何帮助

I want to remove all " from this string: 我想从此字符串中删除所有“:

 let test:NSString = jsonData.valueForKey("test") as! NSString

The method stringByReplacingOccurrencesOfString(_:withString) will do the trick: 方法stringByReplacingOccurrencesOfString(_:withString)将达到目的:

let myString = "\"test\""
let noQuotes = myString.stringByReplacingOccurrencesOfString( "\"", withString: "" )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM