2016-03-30 24 views
2

Hızlı bir yapı hatası alıyorum.'CGPoint' türünün değeri dönüştürülemiyor! Beklenen argüman türü '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) 

      } 
     } 
    } 

Yapılandırma hatası alıyorum 'CGPoint' türünün değeri dönüştürülemiyor! beklenen argüman türü 'UnsafeMutablePointer'

cevap

1

deneyin kullanmadan: CGGlyph:

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

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

Teknik olarak, bu muhtemelen 'var glif olmalıdır? = nil' (ancak = nil' tamamen isteğe bağlı olabilir). Burada çağrılan işlevler [nullability açıklamaları] ile güncelleştirilemez (http://stackoverflow.com/a/29401454/2792531), ancak eğer & nbsp, isteğe bağlı değil, isteğe bağlı olarak işaretlenir. isteğe bağlı değil. Bu işlev kesinlikle üzerine yazmanız için bir değer yaratmanızı beklemiyor ... – nhgrif

İlgili konular