2016-03-30 11 views
2

私は迅速なビルドエラーを取得しています。タイプ 'CGPoint!'の値を変換できません。予想される引数の型に 'UnsafeMutablePointer <CGPoint>'

func pathRefFromText() -> CGPathRef { 

     let attributed : NSAttributedString = self.attrubutedText 
     let line : CTLineRef = CTLineCreateWithAttributedString(attributed as! CFAttributedStringRef) 
     let runArray : CFArrayRef = CTLineGetGlyphRuns(line) 
     for var runIndex = 0; runIndex < CFArrayGetCount(runArray); runIndex++ { 
      let run: CTRunRef = (CFArrayGetValueAtIndex(runArray, runIndex) as! CTRunRef) 
      // let runFont : CTFontRef = CFDictionaryGetValue(CTRunGetAttributes(run), kCTFontAttributeName) 
      for(var runGlyphIndex = 0; runGlyphIndex < CTRunGetGlyphCount(run); runGlyphIndex++) 
      { 
       let thisGlyphRange : CFRange = CFRangeMake(runGlyphIndex, 1) 
       let glyph : CGGlyph! 
       let position : CGPoint! 

       // The build error comes in these two lines 
       CTRunGetGlyphs(run, thisGlyphRange, glyph) 
       CTRunGetPositions(run, thisGlyphRange, position) 

      } 
     } 
    } 

「CGPoint!」タイプの値を変換できませんというビルドエラーが発生しました。期待される引数の型 'UnsafeMutablePointer'

答えて

1

を使用してみてくださいに:CGGlyph:

var glyph : CGGlyph = CGGlyph() 
var position : CGPoint = CGPoint() 

CTRunGetGlyphs(run, thisGlyphRange, &glyph) 
CTRunGetPositions(run, thisGlyphRange, &position) 
+0

技術的には、これはおそらく、 'VARグリフすべきですか? = nil'(ただし、 '= nil'は純粋にオプションです)。ここで呼び出されている関数は[null許容量注釈](http://stackoverflow.com/a/29401454/2792531)で更新されていませんが、そうであれば、必ずオプションではありません。この関数は、あなたが上書きするための値をインスタンス化することを確かに期待しません... – nhgrif

関連する問題