In my project I have the following directory structure for Cards:
And in project I create a simple XML file, from where I could control cards that should be loaded.
<?xml version="1.0" encoding="UTF-8"?> <root>
<flashcards>
<flashcard>
<images>
<image>testcard/testimage1</image>
<image>testcard/testimage2</image>
</images>
</flashcard>
</flashcards>
</root>
The following part of code that should convert image path to UIImage
object
for xmlFlashcardImage in xmlFlashcard["images"]["image"].all {
if let imageName = xmlFlashcardImage.element?.text {
if let image = UIImage(named: imageName) {
flashCard.images.append(image)
} else {
#if DEBUG
NSLog("Coudn't load image with path: \(imageName).")
#endif
}
}
}
I tried to play with FileManager
, but failed too :(