mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Fix deprecation warnings by using UTType APIs.
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
//SOFTWARE.
|
||||
|
||||
#import "OnePasswordExtension.h"
|
||||
@import UniformTypeIdentifiers;
|
||||
|
||||
NSString *const AppExtensionURLStringKey = @"url_string";
|
||||
NSString *const AppExtensionUsernameKey = @"username";
|
||||
@@ -435,7 +436,7 @@ static NSString *const AppExtensionWebViewPageDetails = @"pageDetails";
|
||||
}
|
||||
|
||||
NSItemProvider *itemProvider = extensionItem.attachments.firstObject;
|
||||
if (NO == [itemProvider hasItemConformingToTypeIdentifier:(__bridge NSString *)kUTTypePropertyList]) {
|
||||
if (NO == [itemProvider hasItemConformingToTypeIdentifier:UTTypePropertyList.identifier]) {
|
||||
NSDictionary *userInfo = @{ NSLocalizedDescriptionKey: @"Unexpected data returned by App Extension: extension item attachment does not conform to kUTTypePropertyList type identifier" };
|
||||
NSError *error = [[NSError alloc] initWithDomain:AppExtensionErrorDomain code:AppExtensionErrorCodeUnexpectedData userInfo:userInfo];
|
||||
if (completion) {
|
||||
@@ -445,7 +446,7 @@ static NSString *const AppExtensionWebViewPageDetails = @"pageDetails";
|
||||
}
|
||||
|
||||
|
||||
[itemProvider loadItemForTypeIdentifier:(__bridge NSString *)kUTTypePropertyList options:nil completionHandler:^(NSDictionary *itemDictionary, NSError *itemProviderError) {
|
||||
[itemProvider loadItemForTypeIdentifier:UTTypePropertyList.identifier options:nil completionHandler:^(NSDictionary *itemDictionary, NSError *itemProviderError) {
|
||||
NSError *error = nil;
|
||||
if (itemDictionary.count == 0) {
|
||||
NSLog(@"Failed to loadItemForTypeIdentifier: %@", itemProviderError);
|
||||
|
||||
@@ -13,6 +13,7 @@ import RSCore
|
||||
import Account
|
||||
import Articles
|
||||
import Intents
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
class ActivityManager {
|
||||
|
||||
@@ -218,7 +219,7 @@ private extension ActivityManager {
|
||||
#if os(iOS)
|
||||
func updateReadArticleSearchAttributes(with article: Article) {
|
||||
|
||||
let attributeSet = CSSearchableItemAttributeSet(itemContentType: kUTTypeCompositeContent as String)
|
||||
let attributeSet = CSSearchableItemAttributeSet(itemContentType: UTType.compositeContent.identifier)
|
||||
attributeSet.title = ArticleStringFormatter.truncatedTitle(article)
|
||||
attributeSet.contentDescription = article.summary
|
||||
attributeSet.keywords = makeKeywords(article)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
import UIKit
|
||||
import MobileCoreServices
|
||||
import Account
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
extension MasterFeedViewController: UITableViewDragDelegate {
|
||||
|
||||
@@ -20,7 +21,7 @@ extension MasterFeedViewController: UITableViewDragDelegate {
|
||||
let data = webFeed.url.data(using: .utf8)
|
||||
let itemProvider = NSItemProvider()
|
||||
|
||||
itemProvider.registerDataRepresentation(forTypeIdentifier: kUTTypeURL as String, visibility: .ownProcess) { completion in
|
||||
itemProvider.registerDataRepresentation(forTypeIdentifier: UTType.url.identifier, visibility: .ownProcess) { completion in
|
||||
completion(data, nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import Account
|
||||
import CoreServices
|
||||
import SafariServices
|
||||
import SwiftUI
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
class SettingsViewController: UITableViewController {
|
||||
|
||||
@@ -418,19 +419,10 @@ private extension SettingsViewController {
|
||||
|
||||
func importOPMLDocumentPicker() {
|
||||
|
||||
let utiArray = UTTypeCreateAllIdentifiersForTag(kUTTagClassFilenameExtension, "opml" as NSString, nil)?.takeRetainedValue() as? [String] ?? [String]()
|
||||
|
||||
var opmlUTIs = utiArray
|
||||
.compactMap({ UTTypeCopyDeclaration($0 as NSString)?.takeUnretainedValue() as? [String: Any] })
|
||||
.reduce([String]()) { (result, dict) in
|
||||
return result + dict.values.compactMap({ $0 as? String })
|
||||
}
|
||||
opmlUTIs.append("public.xml")
|
||||
|
||||
let docPicker = UIDocumentPickerViewController(documentTypes: opmlUTIs, in: .import)
|
||||
docPicker.delegate = self
|
||||
docPicker.modalPresentationStyle = .formSheet
|
||||
self.present(docPicker, animated: true)
|
||||
let documentPicker = UIDocumentPickerViewController(forOpeningContentTypes: [UTType.opml, UTType.xml], asCopy: true)
|
||||
documentPicker.delegate = self
|
||||
documentPicker.modalPresentationStyle = .formSheet
|
||||
self.present(documentPicker, animated: true)
|
||||
}
|
||||
|
||||
func exportOPML(sourceView: UIView, sourceRect: CGRect) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import Account
|
||||
import Social
|
||||
import RSCore
|
||||
import RSTree
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
class ShareViewController: SLComposeServiceViewController, ShareFolderPickerControllerDelegate {
|
||||
|
||||
@@ -46,14 +47,14 @@ class ShareViewController: SLComposeServiceViewController, ShareFolderPickerCont
|
||||
// Try to get any HTML that is maybe passed in
|
||||
for item in self.extensionContext!.inputItems as! [NSExtensionItem] {
|
||||
for itemProvider in item.attachments! {
|
||||
if itemProvider.hasItemConformingToTypeIdentifier(kUTTypePropertyList as String) {
|
||||
if itemProvider.hasItemConformingToTypeIdentifier(UTType.propertyList.identifier) {
|
||||
provider = itemProvider
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if provider != nil {
|
||||
provider!.loadItem(forTypeIdentifier: kUTTypePropertyList as String, options: nil, completionHandler: { [weak self] (pList, error) in
|
||||
provider!.loadItem(forTypeIdentifier: UTType.propertyList.identifier, options: nil, completionHandler: { [weak self] (pList, error) in
|
||||
if error != nil {
|
||||
return
|
||||
}
|
||||
@@ -73,14 +74,14 @@ class ShareViewController: SLComposeServiceViewController, ShareFolderPickerCont
|
||||
// Try to get the URL if it is passed in
|
||||
for item in self.extensionContext!.inputItems as! [NSExtensionItem] {
|
||||
for itemProvider in item.attachments! {
|
||||
if itemProvider.hasItemConformingToTypeIdentifier(kUTTypeURL as String) {
|
||||
if itemProvider.hasItemConformingToTypeIdentifier(UTType.url.identifier) {
|
||||
provider = itemProvider
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if provider != nil {
|
||||
provider!.loadItem(forTypeIdentifier: kUTTypeURL as String, options: nil, completionHandler: { [weak self] (urlCoded, error) in
|
||||
provider!.loadItem(forTypeIdentifier: UTType.url.identifier, options: nil, completionHandler: { [weak self] (urlCoded, error) in
|
||||
if error != nil {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user