Swift version of componentsSeparatedByString

后端 未结 4 695
攒了一身酷
攒了一身酷 2020-11-29 08:04

I know its noob question, i really search around before ask. But there is not exact answer of what i want to know. How we split string into the array without using Objectiv

4条回答
  •  醉话见心
    2020-11-29 08:50

    "I know it doesnt work"

    Well, for me, it does. In the Swift REPL:

      1> import Foundation
      2> "a b c".componentsSeparatedByString(" ")
    $R6: String[] = size=3 {
      [0] = {
        core = {
          _baseAddress = Builtin.RawPointer = 0x0000000100407980
          _countAndFlags = -4611686018427387903
          _owner = Some {
            Some = @"a"
          }
        }
      }
      [1] = {
        core = {
          _baseAddress = Builtin.RawPointer = 0x0000000100408e50 -> 0x00007fff7cde0062 (void *)0x001b00007fff7cdd
          _countAndFlags = -4611686018427387903
          _owner = Some {
            Some = @"b"
          }
        }
      }
      [2] = {
        core = {
          _baseAddress = Builtin.RawPointer = 0x0000000100408dd0
          _countAndFlags = -4611686018427387903
          _owner = Some {
            Some = @"c"
          }
        }
      }
    }
    

提交回复
热议问题