Reputation: 890
I'm sorry if it's already discussed, but i don't find the solution
I have a struct:
struct Point2D
{
var x: Double = 0.0
var y: Double = 0.0
}
And I have a class also:
class Letter
{
var points3D: Dictionary<String,Point3D> = [:]
var points2D: Dictionary<String,Point2D> = [:]
var edges: Dictionary<String,Edge> = [:]
}
In some view:
class GraphicView: UIView {
var letter:Letter!
override func drawRect(rect: CGRect) {
for (name,point3d) in letter.points3D {
//Says String isn't convertable to DictionaryIndex<String,Point2D>
letter.points2D[name]!.x = point3d.x * (perspective / (perspective - point3d.z)) + imageWidth/2
letter.points2D[name]!.y = point3d.y * (perspective / (perspective - point3d.z)) + imageHeight/2
}
}
I'm trying to find some value for key (I know it exists) and change variables of this value to another. What's wrong?
Upvotes: 0
Views: 87
Reputation: 51911
Maybe perspective
, imageWidth
or imageHeight
is not Double
?
try:
class GraphicView: UIView {
var letter:Letter!
override func drawRect(rect: CGRect) {
for (name,point3d) in letter.points3D {
letter.points2D[name]!.x = point3d.x * (Double(perspective) / (Double(perspective) - point3d.z)) + Double(imageWidth)/2
letter.points2D[name]!.y = point3d.y * (Double(perspective) / (Double(perspective) - point3d.z)) + Double(imageHeight)/2
}
}
Upvotes: 1