Prowbe
(Prowbe)
1
Hello !
I'm currently encountering a problem, I'm developing a note like application and during the saving process of the note I need to keep the order in wich I added the elements (elements can be text and/or image).
The problem is that in the case where I've got text before and after an image I cannot figure out how to have an Array like [TextBefore, Image, TextAfter].
So my question is, Is it possible to do that and if it is how ? Thanks in advance.
PS : Sorry for my English
Perhaps you can encapsulate the state into an enum:
enum Element {
case text(String)
case image(NSImage)
case textAndImage(String, NSImage)
}
then you can have an array of Elements:
let arr: [Element] = [.text("Hello"), .image(someImage), .textAndImage("World", anotherImage)]
Prowbe
(Prowbe)
3
Thanks for your reply. I can try this now my problem will be the detection of text input.