Kodeco Forums

UICollectionView Tutorial Part 1: Getting Started

Get started with UICollectionView! In part 1 of this collection view tutorial, you'll write a Swift app and learn the basics, including custom cells.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/2132-uicollectionview-tutorial-part-1-getting-started

Could you please update the FlickrSearcher.Swift file included in this demo to support iOS 9? And in that file, there is an error in the error handling line where JSON is used. Kindly fix that too. Thanks for the wonderful tutorial.

Replace that line of code with

let resultsDictionary = try! NSJSONSerialization.JSONObjectWithData(data!, options:NSJSONReadingOptions(rawValue: 0)) as? NSDictionary

Besides, use https instead of http in function flickrImageURL(_:slight_smile: to get image.

return NSURL(string: "https://farm\(farm).staticflickr.com/\(server)/\(photoID)_\(secret)_\(size).jpg")!

That works for me.

Thank you so much! It worked for me. Thanks again!! :slightly_smiling:

I am unable to find api key from this link… Flickr Api Explorer - flickr.photos.search
Any one please help me out to solve my problem

You have to use that page to perform a search, e.g. type “cat” into the text field, then at the bottom of the page will be the search results and the search URL that was used. The URL will contain the api key.

Thanks a lot jrturton for replying :slight_smile:

Hey jrturton, I need this tutorial in objective c but the link provided in this page redirects me to this same page, can you help me with my problem, any help will be appreciated.

Sorry, I think those redirects are now permanent and the original tutorial is no longer available.

Not happy :neutral_face: , anyways thanks for replying.

I updated the project for iOS9 here.

The JSON section that gives an error in iOS8 should be replaced with this to retain the same functionality.

let resultsDictionary: NSDictionary?
do {
resultsDictionary = try NSJSONSerialization.JSONObjectWithData(data!, options:NSJSONReadingOptions(rawValue: 0)) as? NSDictionary
} catch let JSONError as NSError {
completion(results: nil, error: JSONError)
return
}

I needed this tutorial in Objective-C as well. So as an exercise I translated from Swift to Objective-C. You can find the finished source for part 1 here:

https://github.com/nhandyal/iOS-tutorials/tree/RW-UICollectionView-p1

Thanks Nikhil :smile:

I get multiple yellow errors in flickrSearcher on lines: 41, 95 and 149.

The errors on 41 and 95 say: “sendAsynchronousRequest…”

The error on line 149 says: “stringByAddingPercentEscapesUsingEncoding”

How can I fix these?

Thank you so much

https://github.com/biosckon/flickrSearch_By_raywenderlich/

I’m working through the tutorial and fixing all the errors and warnings as I go iOS 9.3

You can find refactored to 9.3 FlickrSearcher.swift

Have fun.