What is a fast way to convert a string of two characters to an array of booleans?

前端 未结 8 1543
我寻月下人不归
我寻月下人不归 2021-02-04 10:24

I have a long string (sometimes over 1000 characters) that I want to convert to an array of boolean values. And it needs to do this many times, very quickly.

let         


        
8条回答
  •  我在风中等你
    2021-02-04 11:08

    Use withCString(_:) to retrieve a raw UnsafePointer. Iterate over that and compare to 49 (ascii value of "1").

提交回复
热议问题