[Baasbox 0.95] Swift file download

29 views
Skip to first unread message

Tobias Marx

unread,
Oct 10, 2016, 11:45:06 AM10/10/16
to BaasBox
Hi!

I'm fairly new to Swift and to Baasbox. I'm trying to download a file with the BAAFile class, but keep running into problems. Could anyone give me an working example?

Many thanks in advance!

Tobias

Luca Cardelli

unread,
Oct 10, 2016, 12:24:24 PM10/10/16
to BaasBox
Hey Tobias,

In order to download a file from BaasBox with the SDK you need to use the method "BAAFile.loadFileWithId"

An example here 

BAAFile.loadFileWithId(id) { (data, error) in

   if ( data != nil ) {

     self.image = UIImage.init(data:data!)!

   }

}



If you are using Swift 3 the methods changes a bit:

BAAFile.load(withId: id) { (data, error) in

   if ( data != nil ) {

       self.image = UIImage(data: data)
      }

}


I hope that these snippets will help you in your development.

Luca

Reply all
Reply to author
Forward
0 new messages