ios - NSGliff for Swift Dictionary Key - Using uintptr_t? -
i need use nsglyph key in swift dictionary
var glyph:nsglyph //set glyph var glyphdict:[nsglyph:cgpath] //will contain cache of glyphs converted paths var path = glyphdict[glyph]
but get:
error: '[nsglyph : cgpath]?' not have member named 'subscript'
so guess apple hasn't defined subscript nsglyph?
i've found code apple's vectortextlayer sample code uses cgglyph key in cfdictionary. how can adapt work in swift dictionary?
cgpathref path = (cgpathref)cfdictionarygetvalue(glyphdict, (const void *)(uintptr_t)glyph);
i understand code wrapping cgglyph uintptr_t. how in swift?
i think you've copied different code in question. error happens when variable you're using dictionary optional, declared as:
var glyphdict:[nsglyph:cgpath]?
to solve issue, can read dictionary using optional chaining:
var path = glyphdict?[glyph]
note path
optional itself.
Comments
Post a Comment