NEW: Subscribe to Hacking with Swift+ and accelerate your learning! >>

SOLVED: Project 1: solving challenge 3...edit: solved.

Forums > 100 Days of Swift

I think I'm massively confused by the relationship between the View Controllers.

where the title is being set is easy so I just changed

title = selectedImage


title = "photo 0 of \(selectedImage?.count ?? 0)"

so I could get the total number... and I thought it was going to be easy once I figured out how to iterate over some list that contained all of the images...

This is harder than I honestly thought it was going to be, I was trying to just use selectedImage?.count and that worked to get me the total number of pictures... well sorta... it gave me 12 and there are only 10. but it was the closest I got so I tried to store it in a range var range = 1...selectedImage?.count so I could iterate over it but then I couldn't get each picture image count...

I read the hint and I'm still not understanding how to do this...

(updating as I work on this, I really feel like this should be easier but how to get access to that list of pictures is really hard)


alright, so reading the hint again after it first made no sense it started making sense...

I guess I didn't understand that by making that DetailViewController have variables they were accessible to me in the tableViewFunction in the ViewController...

I added

vc.selectedImageCount = indexPath.row + 1
vc.totalImageCount = pictures.count

to the ViewController tableView func and changed the title line in DetailViewController to

title = "Photo \(selectedImageCount ?? 0) of \(totalImageCount ?? 0)"

and that appears to have done it. WOW. ok... I learned a lot here.


Rubber Ducking!

see Sean Alllen Programmer Slang


Hacking with Swift is sponsored by Fernando Olivares

SPONSORED Ever ask for help and your reviewer immediately notices issues you missed? Fernando Olivares is a 10-year veteran from Big Nerd Ranch and Lambda School who can help hone your app building skills, and he's just launched a new book that does just that – use the code "hacking" to save $5!

Buy the book

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

Not logged in

Log in

Link copied to your pasteboard.