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      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

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.