NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

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.


I'm having the same problem with the second challenge. Did you find out how to share the entire app? I can share an URL but the app doesn't have an URL


Hi @luciventura!

Your app doesn't have a URL, because it's not in the App Store yet :) Once an app is in the App Store, the URL will appear, no worries.


Hacking with Swift is sponsored by Judo

SPONSORED Let’s face it, SwiftUI previews are limited, slow, and painful. Judo takes a different approach to building visually—think Interface Builder for SwiftUI. Build your interface in a completely visual canvas, then drag and drop into your Xcode project and wire up button clicks to custom code. Download the Mac App and start your free trial today!

Try 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.