string - How do I check to see if a character is a space character in Swift? -


in program i'm writing, need check see if character space (" "). have conditional it's not working. ideas? in advance.

for(var k = indexofcharbeingexamined; k < linebeingexaminedchars.count; k++){      let charbeingexamined = linebeingexaminedchars[linebeingexaminedchars.startindex.advancedby(k)];  //operations      if(string(charbeingexamined) == " "){      //more operations      } } 

the following code works me. note it's easier iterate on characters in string using 'for' (second example below):

var s = "x yz" var = 0; < s.characters.count; i++ {     let x = s[s.startindex.advancedby(i)]     print(x)     print(string(x) == " ") }  c in s.characters {     print(c)     print(string(c) == " ") } 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -