NEW: Start my new Ultimate Portfolio App course with a free Hacking with Swift+ trial! >>

SOLVED_ Project 3 ( Day 22) Challenge 1 & 2

Forums > 100 Days of Swift

  1. In challange 1, Try adding the image name to the list of items that are shared.

    • So the image names are saved in the [pictures] array inside the viewController where my .action button is in the DetailViewController. How can i refer to a variable that is in another viewcontroller? Or do i need to create new variables for the image names inside the same viewController that my .action button is.
  2. Go back to project 1 and add a bar button item to the main view controller that recommends the app to other people.

    • I was able to add a button that shares a text saying " check out this cool app", but are we supposed to share the entire app bundle ? I feel like i don't completely understand what i am supposed to do here.

Thanks so much for your help guys :)


Hello @teekachu! Ok, so the action button is in the DetailViewController. However, to get there the didSelectRowAt indexPath tableView method was invoked from the main ViewController. This instantiates a ViewController and send it the selected element (a String) from the photos array ie the file name of the photo. So, the main ViewController is sending all the required information. You may want to check that the required image and image name made it through to your DetailViewController and for that you would need to create two property names. Then use those to create your UIActivityViewController like this:

        let vc = UIActivityViewController(activityItems: [image, imageName], applicationActivities: [])
        vc.popoverPresentationController?.barButtonItem = navigationItem.rightBarButtonItem
        present(vc, animated: true)

As far as the second challenge there isn't really much more that can be done. If it were an app in the App Store you could send a link to its location or to a product web site, etc.

I hope that helps you out.




Thank you so much ! It did solve my problem, I am so grateful for your help.


Hacking with Swift is sponsored by Essential Developer

SPONSORED From January 26th to 31st you can join a FREE crash course for iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a senior developer!

Save your spot now

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.