UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

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

to

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)

3      

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.

4      

Rubber Ducking!

see Sean Alllen Programmer Slang

3      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

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

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.