You are confusing a lot of things, because you do not use types properly.
var extract = selected.map {$0.rect} // running other functions. mapping out what we need, rect is my rectangle info
let finishedextracting = extract.flatMap() { [$0.0, $0.1, $0.2, $0.3]}
//The error shows the 0, 1, 2, and 3, in 0.0 etc, dont exist in CGRect
I understand extract is a CGRect or probably an array with a CGRect.
So its internal struct is not a 4-uple (x, y, width, height), but a struct (origin: CGPoint, size: CGSize)
so line 2 does not make work.
But you could write:
var extract = selected.map {$0.rect} // running other functions. mapping out what we need, rect is my rectangle info
let finishedExtracting = extract.flatMap() { [$0.origin, $0.size]}
You will get origin and size, as an array of pairs
[(100.0, 40.0), (200.0, 30.0)]
What do you want to get in finishedExtracting ?
- An array with x, y, width, height ?
In such a case, you could replace
var extract = selected.map {$0.rect}
by
var extract = selected.map {$0.rect}[0] // Get the first element
extract is no more an array but a single CGRect, with origin and size properties.
and replace line 2 by
let (x, y, width, height) = (extract.origin.x, extract.origin.y, extract.size.width, extract.size.height)
let finishedExtracting = [x, y, width, height]
- the origin and size ?
In such a case, replace
var extract = selected.map {$0.rect}
by
var extract = selected.map {$0.rect}[0] // Get the first element
extract is no more an array but a single CGRect, with origin and size properties.
and replace line 2 by
let (origin, size) = (extract.origin, extract.size)
Here you cannot set directly finishedExtracting