Apologies
You must be signed in to watch this lesson.
Installing Alamofire Cocoapods and iTunes Search API
Podcasts
Alamofire is an extremely useful networking library for creating responsive applications on the iOS platform. In this lesson, we will go through the steps necessary to integrate Alamofire into our project through Cocoapods. Once we are ready to go with Alamofire, we can look at the iTunes API that allows us to search for anything from AppStore and iTunes Store. This API is fairly straightforward to work with and returns us nicely formatted JSON output. Let's make a network call with Alamofire so we can get a first glimpse at the return data.

Comments (16)
tinypixelpdx
6 years ago
how often should we expect the episodes to be released?
Brian Voong
6 years ago
wealthnut79
6 years ago
Hey Brian, instead of using Itunes API i would like to use my own podcast content from people i will be hosting for. how can i implement this?
Brian Voong
6 years ago
Prabhdeep Singh Randhawa
6 years ago
Come on bryan upload some more.long wait
Brian Voong
6 years ago
Raph
6 years ago
Hi Brian, in the url we forget the = after term, and also the ? before it. How is this possible? Im a bit confused ...
Raph
6 years ago
sorry, wrong video. in the next video that is, in the new Alamofire Request with the method, parameters, etc
Brian Voong
6 years ago
daniel123
6 years ago
For some reason I am getting an HTML response not the json response. Any idea why?
Brian Voong
6 years ago
daniel123
6 years ago
I get a download of the json file. This is the url that I am implementing: https://itunes.apple.com/search?term=\(searchText) When I implement this url in my browser I get a file download with the json: https://itunes.apple.com/search?term=Brianvoong
daniel123
6 years ago
Hi Brian, I still can't seem to get this right. I confirmed that my url is correct but the information that gets printed is in xml format.I have tried to copy and past your whole class but I still can't seem to print the json data. Any idea why I might be getting different information in the console?
Brian Voong
6 years ago
danielb123
6 years ago
Hi Brian, I still can't seem to get this right. I confirmed that my url is correct but the information that gets printed is in xml format.I have tried to copy and past your whole class but I still can't seem to print the json data. Any idea why I might be getting different information in the console?
Brian Voong
6 years ago
daniel123
6 years ago
Sure. In my searchBar( testDidChage) method, I put my networking code: let url = "https://itunes.apple.com/search?term=\(searchText)" Alamofire.request(url).responseData { (dataResponse) in if let err = dataResponse.error { print("Failed to contact yahoo", err) return } guard let data = dataResponse.data else { return } let dummyString = String(data: data, encoding: .utf8) print(dummyString ?? "") } I still see a whole HTML output in the console log. Thanks.
Brian Voong
6 years ago
daniel123
6 years ago
Thank you so much Brian https://github.com/Daniel-Berger/iTunes
Brian Voong
6 years ago
daniel123
6 years ago
WOW! (doh!) Thank you for looking in to this.
ayon
6 years ago
Hey Brain tx for this course. I am loving every bit of it most importantly the way you are not using storyboard. I have some handy dandy knowledge in IOS but always depending on the storyboard. i am learning valuable stuff here. tx a lot man. Btw I am from germany and whenever I am trying to find your pod cast, its all empty. did u delete all of them?
Brian Voong
6 years ago
nombienombie
6 years ago
Hey Brian, once again you have created some awesome content. Amazing work, please can I ask, the picture of your right shoulder, what is it? It looks so familiar and is driving me crazy :)
Brian Voong
6 years ago
spohle
5 years ago
Sorry if the question will be premature and changed or answered later on. Would it be better to do the network request once, maybe at didPresentSearchController and than parse the data in the textDidChange delegate method? making a request for every character I type would put a lot of load on the device making a network request or? so load all podcasts and than search while I'm typing maybe
Brian Voong
5 years ago
Muhammad Junaid
5 years ago
what does encoding .utf8 means
Muhammad Junaid
5 years ago
hi Brian , Awesome work . I want to just know why what does encoding .utf8 means and why we choose .utf8 , why not 16 and others ? Thanks
albaqawi
5 years ago
I had to make my Podfile into the following to avoid many errors as V4.7 did not work source 'https://github.com/CocoaPods/Specs.git' platform :ios, '12.1' use_frameworks! target '<Your Target Name>' do pod 'Alamofire', '~> 4.7' end
albaqawi
5 years ago
sorry to edit pervious comment ----- Podfile ----- source 'https://github.com/CocoaPods/Specs.git' platform :ios, '12.1' use_frameworks! target '<Your Target Name>' do pod 'Alamofire', '~> 4.8' end
dale
5 years ago
Nice vid Brian! Helped me alot. I'll be using Alamofire in my other projects.
dmidler
5 years ago
Brian, thank you so much for this video. Too often learning courses will be like "Go to cocoapods and install Alamofire, come back when thats done." Not that its too difficult, but I just appreciate how you go through it diligently.
Daniel Valera
5 years ago
Hi Brian, I'm really enjoying this course. I just want to give you a feedback about this eLearning Platform that you made: - For me is better to open the Resources link on another tab, I Know that I can "right click->open link in a new tab", but I think is nice if your href from the resources links has the target="_blank". In that way, the video won't interrupt when the user clicked the resources links...
w33zel
5 years ago
Hi Brian I think with the actual version of Alamofire, the "URLEncoding.default" isn't working anymore because it has to be type of ParameterEncoder. I found some things on the internet I don't understand so far, but I came up with another solution like... let params = [ "term": searchText.replacingOccurrences(of: " ", with: "+"), "media": "podcast" ] and the Alamofire request, AF.request(url, parameters: params).responseData..... I also get some better results when I search for some other names with the "+" instead of "%20" or whatever its putting in there. :) But don't know if I will run in some other problems later doing it like this, so lets see what comes, so far enjoying your course. :) I hope everything makes sense, if not, its because I also have to work more on my english. ^^
Brian Voong
5 years ago
DerrickRo
4 years ago
Hey, Brian V. After installing Alamofire and Cocoapods every time I used work .xcworkspace Xcode freeze loading up indexing Text to the point I can't run iPhone simulator or even implement code. I'm using XCode 11.4 please help !
tomasurquijo
4 years ago
Hi Brian, would it be the same if using SPM instead of Cocoapods?
ttanew
3 years ago
Hello, I just followed your lesson 4, 12:13 part. I followed Alamofire.request(url).responseData { (dataResponse) in if let err = dataResponse.error { print("Failed to contact yahoo", err) return } but error was occured. "Module 'Alamofire' has no member named 'request' so what Can I modify it? wait for your reply. Thx!
ttanew
3 years ago
Oh I found the solution. I just changed Alamofire.request to AF.request, and it works now!
HELP & SUPPORT