[ad_1]
EPISODE DOWNLOAD:
Either you want to store your users’ profile picture, sharing photos in your app or building a messenger, you’ll need to know how to upload and download photos.
In this episode, you’ll learn:
– Upload photos to Firebase Storage efficiently
– Download photos from a backend (Firebase)
– Populate data to UITableView, take photos with UIImagePickerController and more
EPISODE DOWNLOAD:
*********
ABOUT CODE MASTERY
*********
Code Mastery is hosted by Duc Tran, founder of Developers Academy.
This is his free-style no notes, no teleprompter presentation and live coding broadcast with you guys everyday.
To join Duc’s free courses, register for free at
*********
MEET DUC TRAN
*********
Duc Tran is founder of Developers Academy, one of the world’s leading iOS, Android and Web development trainers.
More than 2,000,000 developers have studied his video trainings; 100,000 developers see his posts each month. Each year, Duc has helped 20,000 plus developers graduate from his online courses or video series.
*********
FREE TRAININGS IN IOS DEVELOPMENT
*********
To subscribe and get free tutorials, courses and weekly content, visit me at:
Connect with Duc on facebook:
Tweet him:
Get daily inspiration:
===========
CODE IN THIS COURSE
===========
class FeedParser: NSObject, XMLParserDelegate
{
// 2
private var rssItems: [RSSItem] = []
private var currentElement = “”
private var currentTitle: String = “” {
didSet {
currentTitle = currentTitle.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
}
}
private var currentDescription: String = “” {
didSet {
currentDescription = currentDescription.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
}
}
private var currentPubDate: String = “” {
didSet {
currentPubDate = currentPubDate.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
}
}
private var parserCompletionHandler: (([RSSItem]) – Void)?
// 3
func parseFeed(url: String, completionHandler: (([RSSItem]) – Void)?) – Void
{
self.parserCompletionHandler = completionHandler
let request = URLRequest(url: URL(string: url)!)
let urlSession = URLSession.shared
let task = urlSession.dataTask(with: request) { (data, response, error) in
guard let data = data else {
if let error = error {
print(error)
}
return
}
// parse xml data
let parser = XMLParser(data: data)
parser.delegate = self
parser.parse()
}
task.resume()
}
// MARK: – XML Parser Delegate
// 4
func parser(_ parser: XMLParser, didStartElement elementName: String, namespaceURI: String?, qualifiedName qName: String?, attributes attributeDict: [String : String] = [:])
{
// we assign the name of the element to currentElement, if the item tag is found, we reset the temporary variables of title, description and pubdate for later use
currentElement = elementName
if currentElement == “item” {
currentTitle = “”
currentDescription = “”
currentPubDate = “”
}
}
// 5 – when the value of an element is found, this method gets called with a string representation of part of the characters of the current element
func parser(_ parser: XMLParser, foundCharacters string: String)
{
switch currentElement {
case “title”: currentTitle += string
case “description” : currentDescription += string
case “pubDate”: currentPubDate += string
default: break
}
}
// 6 – when we reach the closing tag /item is found, this method gets called
func parser(_ parser: XMLParser, didEndElement elementName: String, namespaceURI: String?, qualifiedName qName: String?)
{
if elementName == “item” {
let rssItem = RSSItem(title: currentTitle, description: currentDescription, pubDate: currentPubDate)
rssItems += [rssItem]
}
Duc Tran, duc Tran iOS, firebase tutorial, firebase swift, firebase tutorial iOS, firebase upload image, firebase upload video, firebase download image, firebase download video, firebase download image from storage, firebase download, storage, file, how to make an app, how to build an app