我正在尝试为 som 天气数据制作我的 xml 解析器的快速版本:
import Cocoa
import Foundation
let string2: NSString? = "cdefg jajaja <time> bbb"
let scanner = NSScanner(string: string2)
scanner.string
let searchString:NSString? = "<time"
var result: NSString? = nil //= AutoreleasingUnsafePointer<NSString?>
scanner.charactersToBeSkipped = nil
scanner.scanString(searchString, intoString: nil) // this is not working (false)
scanner.scanUpToString( ">", intoString: &result) // this is working
result // result = "cdefg jajaja <time"
为什么“scanner.scanString(searchString, intoString: nil)”返回零?