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

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 :)

4      

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.

William

9      

@Will-1-Am

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

3      

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

3      

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.

4      

Hacking with Swift is sponsored by Superwall

SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.

Learn More

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.