小编Jay*_*Jay的帖子

来自Swift Range的NSRange?

问题:当我使用使用Range的Swift String时,NSAttributedString接受NSRange

let text = "Long paragraph saying something goes here!"
let textRange = text.startIndex..<text.endIndex
let attributedString = NSMutableAttributedString(string: text)

text.enumerateSubstringsInRange(textRange, options: NSStringEnumerationOptions.ByWords, { (substring, substringRange, enclosingRange, stop) -> () in

    if (substring == "saying") {
        attributedString.addAttribute(NSForegroundColorAttributeName, value: NSColor.redColor(), range: substringRange)
    }
})
Run Code Online (Sandbox Code Playgroud)

产生以下错误:

错误:'Range'不能转换为'NSRange'aligolsString.addAttribute(NSForegroundColorAttributeName,value:NSColor.redColor(),range:substringRange)

macos ios nsrange swift

153
推荐指数
8
解决办法
11万
查看次数

iOS模拟器声音

有没有办法告诉iOS模拟器您希望它使用哪个音频设备连接到您的计算机?

模拟器似乎选择了上次连接到您机器的任何音频设备.我有一个USB音频设备(fasttrack pro)用于我的主要声音播放,然后是我用于Skype通话的USB耳机.通常情况下,模拟器的音频是在耳机而不是主扬声器上播放的.

iphone ios ios-simulator

13
推荐指数
2
解决办法
2万
查看次数

标签 统计

ios ×2

ios-simulator ×1

iphone ×1

macos ×1

nsrange ×1

swift ×1