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

SOLVED: project 19 kUTTypeProperList and UTTypePropertyList

Forums > 100 Days of Swift

hello again!

xcode is throwing this error at me when I try to follow its advise. Ayone know what's going on?

the entire code is below, but the error is coming from this line here

itemProvider.loadItem(forTypeIdentifier: kUTTypePropertyList as String)

and it says to use UTTypePropertyList instead of kUTTypePropertyList because it's been depreciated in ios 15.0. When I do that, i get this error:

Cannot find 'UTTypePropertyList' in scope


import UIKit
import MobileCoreServices
import UniformTypeIdentifiers

class ActionViewController: UIViewController {

    @IBOutlet weak var imageView: UIImageView!

    override func viewDidLoad() {
        super.viewDidLoad()

        //        if let inputItem = extensionContext?.inputItems.first as? NSExtensionItem {
        //            if let itemProvider = inputItem.attachments?.first{
        //                itemProvider.loadItem(forTypeIdentifier: KUTTypePropertyList as String)
        //                {[weak self] (dict, error) _ in
        //
        //
        //                }
        //            }
        //        }
        //
        //    }

        if let inputItem = extensionContext?.inputItems.first as? NSExtensionItem {
            if let itemProvider = inputItem.attachments?.first {
                itemProvider.loadItem(forTypeIdentifier: UTTypePropertyList as String)
                { [weak self] (dict, error) in
                    guard let itemDictionary = dict as? NSDictionary else{return}
                    guard let javaScriptValues = itemDictionary[NSExtensionJavaScriptPreprocessingResultsKey] as? NSDictionary else {return}
                    print(javaScriptValues)

                }
            }
        }

    }

    @IBAction func done() {
        // Return any edited content to the host app.
        // This template doesn't do anything, so we just echo the passed in items.
        self.extensionContext!.completeRequest(returningItems: self.extensionContext!.inputItems, completionHandler: nil)
    }

}

3      

Hi there! As far as I remember, there were some changes so try using this. It took me some time to find back then, when I was following this course as well :)

itemProvider.loadItem(forTypeIdentifier: UTType.propertyList.identifier as String)

4      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out 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.