通过NSAttributedString进行攻击:“没有更多上下文的表达类型是不明确的”

时间:2015-09-29 00:06:06

标签: swift nsattributedstring

有人可以告诉我出了什么问题吗?

let myTitle = NSAttributedString(string: Xdevices[row].deviceName!,
              attributes: [NSFontAttributeName:UIFont(name: "Georgia", size: 
              15.0)!,NSForegroundColorAttributeName:UIColor.orangeColor(), 
              NSStrikethroughStyleAttributeName: NSUnderlineStyle.StyleSingle])

错误是:

  

如果没有更多的上下文,表达的类型是不明确的

插入NSStrikethroughStyleAttributeName: NSUnderlineStyle.StyleSingle

后发生这种情况

1 个答案:

答案 0 :(得分:10)

试试这个:

  it('assigns a user key properly', function(done) {
    request(app)
      .post('/game/:username')
      .send({
        image: "image/png",
        username: "player1",
        userKey: ""
      })
      .expect(201)
      .expect(res.body.should.have.property("userKey"))

    // .expect()


    .end(function(err, res) {
      if (err) return done(err);

      done();
    })

  })

let attributes = [ NSFontAttributeName: UIFont(name: "Georgia", size: 15.0)!, NSForegroundColorAttributeName: UIColor.orangeColor(), NSStrikethroughStyleAttributeName: NSNumber(integer: NSUnderlineStyle.StyleSingle.rawValue) ] let myTitle = NSAttributedString(string: Xdevices[row].deviceName!, attributes: attributes) 需要一个NSAttributedString(string:attributes:)类型的字典。但是,[String: AnyObject]StyleSingle。因此,您必须将其包装在Int