TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

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      

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

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.