I need to randomize images that are located in Firebase Storage. My initial thought was to use the download links that are provided by Firebase for each image but not sure if that is the best solution. For test purposes I dropped three images into my Xcode project and I've been randomizing those locally but now I need to pick from images in Firebase. I've included the code from the view controller below. I didn't see anything that might answer this question so any thoughts would be greatly appreciated.
import UIKit
import FBSDKCoreKit
import FBSDKLoginKit
import FirebaseDatabase
class SecondViewController: UIViewController {
var ref:FIRDatabaseReference!
@IBOutlet weak var sliderLabel: UILabel!
@IBOutlet weak var verticalSlider: UISlider!
{
didSet{
verticalSlider.transform = CGAffineTransform(rotationAngle: CGFloat(-M_PI_2))
}
}
@IBAction func verticalSliderChanged(_ sender: UISlider) {
var currentValue = Int(sender.value);
sliderLabel?.text = "\(currentValue)"
}
@IBAction func checkmarkButtonPressed(_ sender: Any) {
let img:UIImageView = UIImageView(frame: CGRect(x: 30, y: 180, width: 250, height: 320))
let randomImage = arc4random()
if (randomImage % 4 == 0) {
img.image = UIImage(named: "hero.jpg")
} else if (randomImage % 3 == 1) {
img.image = UIImage(named: "hillary.jpg")
} else {
img.image = UIImage(named: "thistimeisdifferent.png")
//self.ref.child(uuid).child("Book Info").child("Book Title").child("Slider Value").setValue(currentValue)
}
}