I worked on a Swift project in Xcode. I struggled to fix all errors, but I still have 2, keeping my project stuck, as you can see in the code below: @Error1 and @Error2. I hope you could help me! Thank you in advance!
override func viewDidLoad() {
    super.viewDidLoad()
    //Getting the URL of the item
    for item in self.extensionContext!.inputItems {
        if let item = item as? NSExtensionItem {
            for itemProvider in item.attachments! {
                //Going through each item in each input item
                if let itemProvider = itemProvider as? NSItemProvider {
                    if itemProvider.hasItemConformingToTypeIdentifier(kUTTypeURL as String) {
                        //If the item contains a URL 
                        itemProvider.loadItemForTypeIdentifier(kUTTypeURL as String, options: nil, completionHandler: {(content, error) -> Void in
                         dispatch_async(dispatch_get_main_queue()){
                                if let url = content as? URL /*@Error1*/ {
                                    if url.absoluteString("youtube.com") || url.absoluteString.contains("youtu.be") { //@Error1.1
                                        self.setTitleOfTextView("Video")
                                        //Just in case the app isn't running in the background, write the URL to the shared NSUserDefaults
                                        var existingItems = Constants.sharedDefaults.valueForKey(Constants.videosToAdd)// sharedDefaults.value(forKey: Constants.videosToAdd) as! [String]
                                        existingItems.append(url.absoluteString) //@Errror1.2
                                        //Constants.sharedDefaults.set(existingItems, forKey: Constants.videosToAdd)
                                        //Constants.sharedDefaults.synchronize()
                NSUserDefaults.standardUserDefaults().setInteger(yourScore, forKey: "highScore")
                                         NSUserDefaults.standardUserDefaults().synchronize()
                                        //Passing URL    
                                       self.wormhole.passMessageObject(url.absoluteString as NSCoding?, identifier: "youTubeUrl")
                                    return
                                    }
                                }
                                self.setTitleOfTextView("Invalid URL.")
                            }
                        })
                    }
                }
            }
        }
    }
}
@Error1: 'Use of undeclared type
URL'.Please, note that
contentfromif let url = **content** as? URL {...}, is declared as:let content: NSSecureCoding?.Update: If I change the
URLintoNSURLI would get 2 more errors to:@Error1.1 (
if url.absoluteString("youtube.com") || url.absoluteString.contains("youtu.be") {...}): Cannot call value of non-function typeString.@Error1.2 (
existingItems.append(url.absoluteString)): Value of typeAnyObject?has no memberappend.
func setTitleOfTextView(_ text: String) {
    self.mainLabel.text = text
    DispatchQueue.main.asyncAfter(deadline: dispatch_time_t() + Double(Int64(3 * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)) /*@Error2*/ {
        UIView.animate(withDuration: 0.25, animations: {
            self.view.alpha = 0
        }, completion: { completed in
            self.extensionContext?.completeRequest(returningItems: nil) { completed in
                self.dismiss(animated: true, completion: nil)
            }
        })
    }
}
@Error2: 'Use of unresolved identifier
DispatchQueue'.Update: If I change
DispatchQueue.main.asyncAfter(deadline: dispatch_time_t() + Double(Int64(3 * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)) {...}intodispatch_after(dispatch_time_t(), Int64((3 * Double(NSEC_PER_SEC)) / Double(NSEC_PER_SEC)) ) {...}, I still get the error: Argument typeInt64does not conform to expected typedispatch_queue_t(akaOS_dispatch_queue).
                        
Trying to struggle with this piece of code in Swift 2.2 (using Xcode 7) is kinda weird... After you fixed one, another comes out. Switching to Swift 3 (in Xcode 8) makes everything fast and clean.