I really haven't used Firebase, but for what I understand here, you want to download the image from each link and save all the images in an array. You can achieve that by doing this:
//Get all URLS in an NSArray
let urlsArray:NSArray = ["https://firebasestorage.googleapis.com/v0/b/motive-73352.appspot.com/o/Content%2F20170525130622.jpg?alt=media&token=1e654c60-2f47-43c3-9298-b0282d27f66c","https://firebasestorage.googleapis.com/v0/b/motive-73352.appspot.com/o/20170525131400.mp4?alt=media&token=30fd962d-c305-4fa4-955d-dbb06ef91623"]
//Create a NSMutableArray where the final images will be saved.
let imagesArray:NSMutableArray! = NSMutableArray()
//Create a for that checks every link in the urlsArray.
for x in 0..<urlsArray.count
{
//Set the urlsArray content at position x as a URL
let imageUrl:URL = URL(string: urlsArray.object(at: x) as! String)!
//Generate a request with the current imageUrl.
let request:URLRequest = URLRequest.init(url: imageUrl)
//Start a NSURLConnection and get a Data that represents your image.
NSURLConnection.sendAsynchronousRequest(request, queue: OperationQueue.main, completionHandler: { (response, imageDta, error) in
//Store the received data as an UIImage.
let imageReceived:UIImage = UIImage(data: imageDta!)!
//Save the image to our imagesArray.
imagesArray.add(imageReceived)
})
//The Process loops until you get all the images.
}
UPDATE
Sure you can, the only thing here is that I removed your last object from your array because it contains a nil object and Swift can't candle nil objects:
//Using the NSArray style you're using.
let yourFireBaseArray = [FirebaseTest.storiesContent(storyUrl: https://firebasestorage.googleapis.com/v0/b/motive-73352.appspot.com/o/Content%2F20170525130622.jpg?alt=media&token=1e654c60-2f47-43c3-9298-b0282d27f66c), FirebaseTest.storiesContent(storyUrl: https://firebasestorage.googleapis.com/v0/b/motive-73352.appspot.com/o/20170525131400.mp4?alt=media&token=30fd962d-c305-4fa4-955d-dbb06ef91623)]
//Create a NSMutableArray where the final images will be saved.
let imagesArray:NSMutableArray! = NSMutableArray()
//Create a for that checks every link in the yourFireBaseArray.
for x in 0..<yourFireBaseArray.count
{
//Get your current array position string as a storiesContent object
let fireBaseString:storiesContent = yourFireBaseArray.object(at: x) as! storiesContent
//Use your fireBaseString object, get the storyURL string and set it in an URL.
let imageUrl:URL = URL(string: fireBaseString.storyURL)!
//Generate a request with the current imageUrl.
let request:URLRequest = URLRequest.init(url: imageUrl)
//Start a NSURLConnection and get a Data that represents your image.
NSURLConnection.sendAsynchronousRequest(request, queue: OperationQueue.main, completionHandler: { (response, imageDta, error) in
//Store the received data as an UIImage.
let imageReceived:UIImage = UIImage(data: imageDta!)!
//Save the image to our imagesArray.
imagesArray.add(imageReceived)
})
//The Process loops until you get all the images.
}
UPDATE 2
Okay, this is my example project, copy and paste and it will give you the resulted image.
import UIKit
class ViewController: UIViewController {
@IBOutlet var image:UIImageView!
var urlArray:NSMutableArray! = NSMutableArray()
var imagesArray:NSMutableArray! = NSMutableArray()
override func viewDidLoad() {
super.viewDidLoad()
urlArray = NSMutableArray.init(array: ["https://firebasestorage.googleapis.com/v0/b/motive-73352.appspot.com/o/Content%2F20170525130622.jpg?alt=media&token=1e654c60-2f47-43c3-9298-b0282d27f66c"])
// Do any additional setup after loading the view, typically from a nib.
}
override func viewDidAppear(_ animated: Bool) {
for x in 0..<urlArray.count
{
let imageUrl:URL = URL(string: "\(urlArray.object(at: x) as! String)")!
let request:URLRequest = URLRequest.init(url: imageUrl)
NSURLConnection.sendAsynchronousRequest(request, queue: OperationQueue.main, completionHandler: { (response, imageDta, error) in
if (error == nil)
{
self.imagesArray.add(UIImage(data: imageDta!)!)
if self.imagesArray.count > 0
{
self.image.image = self.imagesArray.object(at: 0) as! UIImage
}
}else{
print("ERROR - \(error!)")
}
})
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
