无法转换'CGPoint'类型的值预期的参数类型'UnsafeMutablePointer <cgpoint>'

时间:2016-03-30 11:55:15

标签: ios swift quartz-core

我一直在快速构建错误。

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 个答案:

答案 0 :(得分:1)

尝试使用:

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

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