diff --git a/Frameworks/Account/Account.swift b/Frameworks/Account/Account.swift index 4c9258c83..23a612b5c 100644 --- a/Frameworks/Account/Account.swift +++ b/Frameworks/Account/Account.swift @@ -8,6 +8,8 @@ #if os(iOS) import UIKit +#elseif os(macOS) +import AppKit #endif import Foundation @@ -530,7 +532,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, } public func opmlDocument() -> String { - let escapedTitle = nameForDisplay.rs_stringByEscapingSpecialXMLCharacters() + let escapedTitle = nameForDisplay.escapingSpecialXMLCharacters let openingText = """ @@ -543,7 +545,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container, """ - let middleText = OPMLString(indentLevel: 0, strictConformance: false) + let middleText = OPMLString(indentLevel: 0, allowCustomAttributes: true) let closingText = """ @@ -1177,13 +1179,13 @@ extension Account { extension Account: OPMLRepresentable { - public func OPMLString(indentLevel: Int, strictConformance: Bool) -> String { + public func OPMLString(indentLevel: Int, allowCustomAttributes: Bool) -> String { var s = "" for feed in topLevelFeeds { - s += feed.OPMLString(indentLevel: indentLevel + 1, strictConformance: strictConformance) + s += feed.OPMLString(indentLevel: indentLevel + 1, allowCustomAttributes: allowCustomAttributes) } for folder in folders! { - s += folder.OPMLString(indentLevel: indentLevel + 1, strictConformance: strictConformance) + s += folder.OPMLString(indentLevel: indentLevel + 1, allowCustomAttributes: allowCustomAttributes) } return s } diff --git a/Frameworks/Account/AccountManager.swift b/Frameworks/Account/AccountManager.swift index a56336673..a004c48b5 100644 --- a/Frameworks/Account/AccountManager.swift +++ b/Frameworks/Account/AccountManager.swift @@ -21,7 +21,7 @@ public final class AccountManager: UnreadCountProvider { public static let shared = AccountManager() public let defaultAccount: Account - private let accountsFolder = RSDataSubfolder(nil, "Accounts")! + private let accountsFolder = Platform.dataSubfolder(forApplication: nil, folderName: "Accounts")! private var accountsDictionary = [String: Account]() private let defaultAccountFolderName = "OnMyMac" @@ -312,7 +312,7 @@ private struct AccountSpecifier { init?(folderPath: String) { - if !FileManager.default.rs_fileIsFolder(folderPath) { + if !FileManager.default.isFolder(atPath: folderPath) { return nil } diff --git a/Frameworks/Account/Feed.swift b/Frameworks/Account/Feed.swift index 397753161..e9566d25b 100644 --- a/Frameworks/Account/Feed.swift +++ b/Frameworks/Account/Feed.swift @@ -31,7 +31,7 @@ public final class Feed: DisplayNameProvider, Renamable, UnreadCountProvider, Ha } set { if let url = newValue { - metadata.homePageURL = url.rs_normalizedURL() + metadata.homePageURL = url.normalizedURL } else { metadata.homePageURL = nil @@ -226,7 +226,7 @@ public final class Feed: DisplayNameProvider, Renamable, UnreadCountProvider, Ha extension Feed: OPMLRepresentable { - public func OPMLString(indentLevel: Int, strictConformance: Bool) -> String { + public func OPMLString(indentLevel: Int, allowCustomAttributes: Bool) -> String { // https://github.com/brentsimmons/NetNewsWire/issues/527 // Don’t use nameForDisplay because that can result in a feed name "Untitled" written to disk, // which NetNewsWire may take later to be the actual name. @@ -237,16 +237,16 @@ extension Feed: OPMLRepresentable { if nameToUse == nil { nameToUse = "" } - let escapedName = nameToUse!.rs_stringByEscapingSpecialXMLCharacters() + let escapedName = nameToUse!.escapingSpecialXMLCharacters var escapedHomePageURL = "" if let homePageURL = homePageURL { - escapedHomePageURL = homePageURL.rs_stringByEscapingSpecialXMLCharacters() + escapedHomePageURL = homePageURL.escapingSpecialXMLCharacters } - let escapedFeedURL = url.rs_stringByEscapingSpecialXMLCharacters() + let escapedFeedURL = url.escapingSpecialXMLCharacters var s = "\n" - s = s.rs_string(byPrependingNumberOfTabs: indentLevel) + s = s.prepending(tabCount: indentLevel) return s } diff --git a/Frameworks/Account/FeedFinder/FeedFinder.swift b/Frameworks/Account/FeedFinder/FeedFinder.swift index 479598248..8044295fa 100644 --- a/Frameworks/Account/FeedFinder/FeedFinder.swift +++ b/Frameworks/Account/FeedFinder/FeedFinder.swift @@ -124,7 +124,7 @@ private extension FeedFinder { } static func isHTML(_ data: Data) -> Bool { - return (data as NSData).rs_dataIsProbablyHTML() + return data.isProbablyHTML } static func downloadFeedSpecifiers(_ downloadFeedSpecifiers: Set, feedSpecifiers: [String: FeedSpecifier], completion: @escaping (Result, Error>) -> Void) { diff --git a/Frameworks/Account/FeedFinder/FeedSpecifier.swift b/Frameworks/Account/FeedFinder/FeedSpecifier.swift index 6fd51ce5e..5b48b1b98 100644 --- a/Frameworks/Account/FeedFinder/FeedSpecifier.swift +++ b/Frameworks/Account/FeedFinder/FeedSpecifier.swift @@ -69,13 +69,13 @@ private extension FeedSpecifier { score = score + 50 } - if urlString.rs_caseInsensitiveContains("comments") { + if urlString.caseInsensitiveContains("comments") { score = score - 10 } - if urlString.rs_caseInsensitiveContains("podcast") { + if urlString.caseInsensitiveContains("podcast") { score = score - 10 } - if urlString.rs_caseInsensitiveContains("rss") { + if urlString.caseInsensitiveContains("rss") { score = score + 5 } if urlString.hasSuffix("/feed/") { @@ -84,15 +84,15 @@ private extension FeedSpecifier { if urlString.hasSuffix("/feed") { score = score + 4 } - if urlString.rs_caseInsensitiveContains("json") { + if urlString.caseInsensitiveContains("json") { score = score + 6 } if let title = title { - if title.rs_caseInsensitiveContains("comments") { + if title.caseInsensitiveContains("comments") { score = score - 10 } - if title.rs_caseInsensitiveContains("json") { + if title.caseInsensitiveContains("json") { score = score + 1 } } diff --git a/Frameworks/Account/FeedFinder/HTMLFeedFinder.swift b/Frameworks/Account/FeedFinder/HTMLFeedFinder.swift index ff4baa2a2..e8f242a56 100644 --- a/Frameworks/Account/FeedFinder/HTMLFeedFinder.swift +++ b/Frameworks/Account/FeedFinder/HTMLFeedFinder.swift @@ -33,7 +33,7 @@ class HTMLFeedFinder { for oneBodyLink in bodyLinks { if linkMightBeFeed(oneBodyLink) { - let normalizedURL = oneBodyLink.urlString.rs_normalizedURL() + let normalizedURL = oneBodyLink.urlString.normalizedURL let oneFeedSpecifier = FeedSpecifier(title: oneBodyLink.text, urlString: normalizedURL, source: .HTMLLink) addFeedSpecifier(oneFeedSpecifier) } diff --git a/Frameworks/Account/Folder.swift b/Frameworks/Account/Folder.swift index 9cfd52e18..446b49efa 100644 --- a/Frameworks/Account/Folder.swift +++ b/Frameworks/Account/Folder.swift @@ -137,34 +137,34 @@ private extension Folder { extension Folder: OPMLRepresentable { - public func OPMLString(indentLevel: Int, strictConformance: Bool) -> String { + public func OPMLString(indentLevel: Int, allowCustomAttributes: Bool) -> String { let attrExternalID: String = { - if !strictConformance, let externalID = externalID { + if allowCustomAttributes, let externalID = externalID { return " nnw_externalID=\"\(externalID)\"" } else { return "" } }() - let escapedTitle = nameForDisplay.rs_stringByEscapingSpecialXMLCharacters() + let escapedTitle = nameForDisplay.escapingSpecialXMLCharacters var s = "\n" - s = s.rs_string(byPrependingNumberOfTabs: indentLevel) + s = s.prepending(tabCount: indentLevel) var hasAtLeastOneChild = false for feed in topLevelFeeds { - s += feed.OPMLString(indentLevel: indentLevel + 1, strictConformance: strictConformance) + s += feed.OPMLString(indentLevel: indentLevel + 1, allowCustomAttributes: allowCustomAttributes) hasAtLeastOneChild = true } if !hasAtLeastOneChild { s = "\n" - s = s.rs_string(byPrependingNumberOfTabs: indentLevel) + s = s.prepending(tabCount: indentLevel) return s } - s = s + NSString.rs_string(withNumberOfTabs: indentLevel) + "\n" + s = s + String(tabCount: indentLevel) + "\n" return s } diff --git a/Frameworks/Account/LocalAccount/LocalAccountRefresher.swift b/Frameworks/Account/LocalAccount/LocalAccountRefresher.swift index 90718a233..8a2078164 100644 --- a/Frameworks/Account/LocalAccount/LocalAccountRefresher.swift +++ b/Frameworks/Account/LocalAccount/LocalAccountRefresher.swift @@ -57,7 +57,7 @@ extension LocalAccountRefresher: DownloadSessionDelegate { return } - let dataHash = (data as NSData).rs_md5HashString() + let dataHash = data.md5String if dataHash == feed.contentHash { return } @@ -110,6 +110,6 @@ private extension Data { func isDefinitelyNotFeed() -> Bool { // We only detect a few image types for now. This should get fleshed-out at some later date. - return (self as NSData).rs_dataIsImage() + return self.isImage } } diff --git a/Frameworks/Articles/DatabaseID.swift b/Frameworks/Articles/DatabaseID.swift index 392ca1870..86b6dc5de 100644 --- a/Frameworks/Articles/DatabaseID.swift +++ b/Frameworks/Articles/DatabaseID.swift @@ -26,7 +26,7 @@ public func databaseIDWithString(_ s: String) -> String { return identifier } - let identifier = (s as NSString).rs_md5Hash() + let identifier = s.md5String databaseIDCache[s] = identifier return identifier } diff --git a/Frameworks/ArticlesDatabase/ArticlesTable.swift b/Frameworks/ArticlesDatabase/ArticlesTable.swift index 0afc9bb74..14be4a591 100644 --- a/Frameworks/ArticlesDatabase/ArticlesTable.swift +++ b/Frameworks/ArticlesDatabase/ArticlesTable.swift @@ -26,8 +26,8 @@ final class ArticlesTable: DatabaseTable { }() // TODO: update articleCutoffDate as time passes and based on user preferences. - private var articleCutoffDate = NSDate.rs_dateWithNumberOfDays(inThePast: 3 * 31)! - private var maximumArticleCutoffDate = NSDate.rs_dateWithNumberOfDays(inThePast: 4 * 31)! + private var articleCutoffDate = Date().bySubtracting(days: 3 * 31) + private var maximumArticleCutoffDate = Date().bySubtracting(days: 4 * 31) private typealias ArticlesFetchMethod = (FMDatabase) -> Set
diff --git a/Frameworks/ArticlesDatabase/SearchTable.swift b/Frameworks/ArticlesDatabase/SearchTable.swift index 8007b366d..a5ee65fc6 100644 --- a/Frameworks/ArticlesDatabase/SearchTable.swift +++ b/Frameworks/ArticlesDatabase/SearchTable.swift @@ -33,7 +33,7 @@ final class ArticleSearchInfo: Hashable { lazy var bodyForIndex: String = { let s = preferredText.rsparser_stringByDecodingHTMLEntities() - return s.rs_string(byStrippingHTML: 0).rs_stringWithCollapsedWhitespace() + return s.strippingHTML().collapsingWhitespace }() init(articleID: String, title: String?, contentHTML: String?, contentText: String?, summary: String?, searchRowID: Int?) { diff --git a/Mac/CrashReporter/CrashReporter.swift b/Mac/CrashReporter/CrashReporter.swift index be0a8b9f5..ddd3e5ad5 100644 --- a/Mac/CrashReporter/CrashReporter.swift +++ b/Mac/CrashReporter/CrashReporter.swift @@ -30,7 +30,7 @@ struct CrashLog { return nil } self.content = s - self.contentHash = s.rs_md5Hash() + self.contentHash = s.md5String self.path = path self.modificationDate = modificationDate } diff --git a/Mac/MainWindow/AddFeed/AddFeedController.swift b/Mac/MainWindow/AddFeed/AddFeedController.swift index 3760dbe88..1e75a543a 100644 --- a/Mac/MainWindow/AddFeed/AddFeedController.swift +++ b/Mac/MainWindow/AddFeed/AddFeedController.swift @@ -98,8 +98,8 @@ class AddFeedController: AddFeedWindowControllerDelegate { private extension AddFeedController { var urlStringFromPasteboard: String? { - if let urlString = NSPasteboard.rs_urlString(from: NSPasteboard.general) { - return urlString.rs_normalizedURL() + if let urlString = NSPasteboard.urlString(from: NSPasteboard.general) { + return urlString.normalizedURL } return nil } diff --git a/Mac/MainWindow/AddFeed/AddFeedWindowController.swift b/Mac/MainWindow/AddFeed/AddFeedWindowController.swift index 386a7fc29..8ac12d69d 100644 --- a/Mac/MainWindow/AddFeed/AddFeedWindowController.swift +++ b/Mac/MainWindow/AddFeed/AddFeedWindowController.swift @@ -36,7 +36,7 @@ class AddFeedWindowController : NSWindowController { private var userEnteredTitle: String? { var s = nameTextField.stringValue - s = s.rs_stringWithCollapsedWhitespace() + s = s.collapsingWhitespace if s.isEmpty { return nil } @@ -94,7 +94,7 @@ class AddFeedWindowController : NSWindowController { @IBAction func addFeed(_ sender: Any?) { let urlString = urlTextField.stringValue - let normalizedURLString = (urlString as NSString).rs_normalizedURL() + let normalizedURLString = urlString.normalizedURL if normalizedURLString.isEmpty { cancelSheet() @@ -137,7 +137,7 @@ class AddFeedWindowController : NSWindowController { private extension AddFeedWindowController { private func updateUI() { - addButton.isEnabled = urlTextField.stringValue.rs_stringMayBeURL() + addButton.isEnabled = urlTextField.stringValue.mayBeURL } func cancelSheet() { diff --git a/Mac/MainWindow/Detail/DetailStatusBarView.swift b/Mac/MainWindow/Detail/DetailStatusBarView.swift index 0d1bfb6de..eea5f72d2 100644 --- a/Mac/MainWindow/Detail/DetailStatusBarView.swift +++ b/Mac/MainWindow/Detail/DetailStatusBarView.swift @@ -67,7 +67,7 @@ private extension DetailStatusBarView { func updateLinkForDisplay() { if let mouseoverLink = mouseoverLink, !mouseoverLink.isEmpty { - linkForDisplay = (mouseoverLink as NSString).rs_stringByStrippingHTTPOrHTTPSScheme() + linkForDisplay = mouseoverLink.strippingHTTPOrHTTPSScheme } else { linkForDisplay = nil diff --git a/Mac/MainWindow/NNW3/NNW3Document.swift b/Mac/MainWindow/NNW3/NNW3Document.swift index 536f5500d..f9bdcacc2 100644 --- a/Mac/MainWindow/NNW3/NNW3Document.swift +++ b/Mac/MainWindow/NNW3/NNW3Document.swift @@ -32,7 +32,7 @@ struct NNW3Document { extension NNW3Document: OPMLRepresentable { - func OPMLString(indentLevel: Int, strictConformance: Bool) -> String { + func OPMLString(indentLevel: Int, allowCustomAttributes: Bool) -> String { var s = """ @@ -46,7 +46,7 @@ extension NNW3Document: OPMLRepresentable { if let children = children { for child in children { - s += child.OPMLString(indentLevel: indentLevel + 1, strictConformance: true) + s += child.OPMLString(indentLevel: indentLevel + 1, allowCustomAttributes: false) } } @@ -94,19 +94,19 @@ private struct NNW3Folder { extension NNW3Folder: OPMLRepresentable { - func OPMLString(indentLevel: Int, strictConformance: Bool) -> String { - let t = title?.rs_stringByEscapingSpecialXMLCharacters() ?? "" + func OPMLString(indentLevel: Int, allowCustomAttributes: Bool) -> String { + let t = title?.escapingSpecialXMLCharacters ?? "" guard let children = children else { // Empty folder. - return "\n".rs_string(byPrependingNumberOfTabs: indentLevel) + return "\n".prepending(tabCount: indentLevel) } - var s = "\n".rs_string(byPrependingNumberOfTabs: indentLevel) + var s = "\n".prepending(tabCount: indentLevel) for child in children { - s += child.OPMLString(indentLevel: indentLevel + 1, strictConformance: true) + s += child.OPMLString(indentLevel: indentLevel + 1, allowCustomAttributes: false) } - s += "\n".rs_string(byPrependingNumberOfTabs: indentLevel) + s += "\n".prepending(tabCount: indentLevel) return s } } @@ -130,13 +130,13 @@ private struct NNW3Feed { extension NNW3Feed: OPMLRepresentable { - func OPMLString(indentLevel: Int, strictConformance: Bool) -> String { - let t = title?.rs_stringByEscapingSpecialXMLCharacters() ?? "" - let p = homePageURL?.rs_stringByEscapingSpecialXMLCharacters() ?? "" - let f = feedURL?.rs_stringByEscapingSpecialXMLCharacters() ?? "" + func OPMLString(indentLevel: Int, allowCustomAttributes: Bool) -> String { + let t = title?.escapingSpecialXMLCharacters ?? "" + let p = homePageURL?.escapingSpecialXMLCharacters ?? "" + let f = feedURL?.escapingSpecialXMLCharacters ?? "" var s = "\n" - s = s.rs_string(byPrependingNumberOfTabs: indentLevel) + s = s.prepending(tabCount: indentLevel) return s } diff --git a/Mac/MainWindow/NNW3/NNW3ImportController.swift b/Mac/MainWindow/NNW3/NNW3ImportController.swift index f3103e1e1..c1ae65a1b 100644 --- a/Mac/MainWindow/NNW3/NNW3ImportController.swift +++ b/Mac/MainWindow/NNW3/NNW3ImportController.swift @@ -93,7 +93,7 @@ private extension NNW3ImportController { guard let document = NNW3Document(subscriptionsPlistURL: url) else { return nil } - let opml = document.OPMLString(indentLevel: 0, strictConformance: true) + let opml = document.OPMLString(indentLevel: 0, allowCustomAttributes: false) let opmlURL = FileManager.default.temporaryDirectory.appendingPathComponent("NNW3.opml") do { diff --git a/Mac/MainWindow/Sidebar/Cell/SidebarCell.swift b/Mac/MainWindow/Sidebar/Cell/SidebarCell.swift index 3df7366e6..5ef2ae6f6 100644 --- a/Mac/MainWindow/Sidebar/Cell/SidebarCell.swift +++ b/Mac/MainWindow/Sidebar/Cell/SidebarCell.swift @@ -143,9 +143,9 @@ private extension SidebarCell { } func layoutWith(_ layout: SidebarCellLayout) { - faviconImageView.rs_setFrameIfNotEqual(layout.faviconRect) - titleView.rs_setFrameIfNotEqual(layout.titleRect) - unreadCountView.rs_setFrameIfNotEqual(layout.unreadCountRect) + faviconImageView.setFrame(ifNotEqualTo: layout.faviconRect) + titleView.setFrame(ifNotEqualTo: layout.titleRect) + unreadCountView.setFrame(ifNotEqualTo: layout.unreadCountRect) } } diff --git a/Mac/MainWindow/Sidebar/Cell/SidebarCellLayout.swift b/Mac/MainWindow/Sidebar/Cell/SidebarCellLayout.swift index 90b2aba1f..e054b924a 100644 --- a/Mac/MainWindow/Sidebar/Cell/SidebarCellLayout.swift +++ b/Mac/MainWindow/Sidebar/Cell/SidebarCellLayout.swift @@ -24,7 +24,7 @@ struct SidebarCellLayout { var rFavicon = NSRect.zero if shouldShowImage { rFavicon = NSRect(x: 0.0, y: 0.0, width: appearance.imageSize.width, height: appearance.imageSize.height) - rFavicon = RSRectCenteredVerticallyInRect(rFavicon, bounds) + rFavicon = rFavicon.centeredVertically(in: bounds) } self.faviconRect = rFavicon @@ -34,7 +34,7 @@ struct SidebarCellLayout { if shouldShowImage { rTextField.origin.x = NSMaxX(rFavicon) + appearance.imageMarginRight } - rTextField = RSRectCenteredVerticallyInRect(rTextField, bounds) + rTextField = rTextField.centeredVertically(in: bounds) let unreadCountSize = unreadCountView.intrinsicContentSize let unreadCountIsHidden = unreadCountView.unreadCount < 1 @@ -43,7 +43,7 @@ struct SidebarCellLayout { if !unreadCountIsHidden { rUnread.size = unreadCountSize rUnread.origin.x = NSMaxX(bounds) - unreadCountSize.width - rUnread = RSRectCenteredVerticallyInRect(rUnread, bounds) + rUnread = rUnread.centeredVertically(in: bounds) let textFieldMaxX = NSMinX(rUnread) - appearance.unreadCountMarginLeft if NSMaxX(rTextField) > textFieldMaxX { rTextField.size.width = textFieldMaxX - NSMinX(rTextField) diff --git a/Mac/MainWindow/Sidebar/PasteboardFeed.swift b/Mac/MainWindow/Sidebar/PasteboardFeed.swift index 5e0bc89e3..f92ad2c31 100644 --- a/Mac/MainWindow/Sidebar/PasteboardFeed.swift +++ b/Mac/MainWindow/Sidebar/PasteboardFeed.swift @@ -37,9 +37,9 @@ struct PasteboardFeed: Hashable { let isLocalFeed: Bool init(url: String, feedID: String?, homePageURL: String?, name: String?, editedName: String?, accountID: String?, accountType: AccountType?) { - self.url = url.rs_normalizedURL() + self.url = url.normalizedURL self.feedID = feedID - self.homePageURL = homePageURL?.rs_normalizedURL() + self.homePageURL = homePageURL?.normalizedURL self.name = name self.editedName = editedName self.accountID = accountID @@ -93,7 +93,7 @@ struct PasteboardFeed: Hashable { } if let foundType = pasteboardType { if let possibleURLString = pasteboardItem.string(forType: foundType) { - if possibleURLString.rs_stringMayBeURL() { + if possibleURLString.mayBeURL { self.init(url: possibleURLString, feedID: nil, homePageURL: nil, name: nil, editedName: nil, accountID: nil, accountType: nil) return } diff --git a/Mac/MainWindow/Timeline/ArticlePasteboardWriter.swift b/Mac/MainWindow/Timeline/ArticlePasteboardWriter.swift index b6fbe97f1..f587b0e02 100644 --- a/Mac/MainWindow/Timeline/ArticlePasteboardWriter.swift +++ b/Mac/MainWindow/Timeline/ArticlePasteboardWriter.swift @@ -77,7 +77,7 @@ private extension ArticlePasteboardWriter { s += "\(summary)\n\n" } else if let html = article.contentHTML { - let convertedHTML = html.rs_stringByConvertingToPlainText() + let convertedHTML = html.convertingToPlainText() s += "\(convertedHTML)\n\n" } diff --git a/Mac/MainWindow/Timeline/Cell/TimelineAvatarView.swift b/Mac/MainWindow/Timeline/Cell/TimelineAvatarView.swift index e84ec4a08..d8cb05e81 100644 --- a/Mac/MainWindow/Timeline/Cell/TimelineAvatarView.swift +++ b/Mac/MainWindow/Timeline/Cell/TimelineAvatarView.swift @@ -63,7 +63,7 @@ final class TimelineAvatarView: NSView { } override func resizeSubviews(withOldSize oldSize: NSSize) { - imageView.rs_setFrameIfNotEqual(rectForImageView()) + imageView.setFrame(ifNotEqualTo: rectForImageView()) } override func draw(_ dirtyRect: NSRect) { diff --git a/Mac/MainWindow/Timeline/Cell/TimelineTableCellView.swift b/Mac/MainWindow/Timeline/Cell/TimelineTableCellView.swift index 22a1628dd..62959de12 100644 --- a/Mac/MainWindow/Timeline/Cell/TimelineTableCellView.swift +++ b/Mac/MainWindow/Timeline/Cell/TimelineTableCellView.swift @@ -116,12 +116,12 @@ class TimelineTableCellView: NSTableCellView { setFrame(for: summaryView, rect: layoutRects.summaryRect) setFrame(for: textView, rect: layoutRects.textRect) - dateView.rs_setFrameIfNotEqual(layoutRects.dateRect) - unreadIndicatorView.rs_setFrameIfNotEqual(layoutRects.unreadIndicatorRect) - feedNameView.rs_setFrameIfNotEqual(layoutRects.feedNameRect) - avatarView.rs_setFrameIfNotEqual(layoutRects.avatarImageRect) - starView.rs_setFrameIfNotEqual(layoutRects.starRect) - separatorView.rs_setFrameIfNotEqual(layoutRects.separatorRect) + dateView.setFrame(ifNotEqualTo: layoutRects.dateRect) + unreadIndicatorView.setFrame(ifNotEqualTo: layoutRects.unreadIndicatorRect) + feedNameView.setFrame(ifNotEqualTo: layoutRects.feedNameRect) + avatarView.setFrame(ifNotEqualTo: layoutRects.avatarImageRect) + starView.setFrame(ifNotEqualTo: layoutRects.starRect) + separatorView.setFrame(ifNotEqualTo: layoutRects.separatorRect) } } @@ -172,7 +172,7 @@ private extension TimelineTableCellView { } else { showView(textField) - textField.rs_setFrameIfNotEqual(rect) + textField.setFrame(ifNotEqualTo: rect) } } diff --git a/Mac/MainWindow/Timeline/TimelineViewController.swift b/Mac/MainWindow/Timeline/TimelineViewController.swift index 6f4dccc34..46f6f036f 100644 --- a/Mac/MainWindow/Timeline/TimelineViewController.swift +++ b/Mac/MainWindow/Timeline/TimelineViewController.swift @@ -256,7 +256,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr tableView.scrollTo(row: 0, extraHeight: 0) } - tableView.rs_selectRow(nextRowIndex) + tableView.selectRow(nextRowIndex) let followingRowIndex = nextRowIndex - 1 if followingRowIndex < 0 { @@ -278,7 +278,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr tableView.scrollTo(row: tableMaxIndex, extraHeight: 0) } - tableView.rs_selectRow(nextRowIndex) + tableView.selectRow(nextRowIndex) let followingRowIndex = nextRowIndex + 1 if followingRowIndex > tableMaxIndex { @@ -383,7 +383,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr return } NSCursor.setHiddenUntilMouseMoves(true) - tableView.rs_selectRow(ix) + tableView.selectRow(ix) tableView.scrollTo(row: ix) } @@ -405,7 +405,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr window.makeFirstResponderUnlessDescendantIsFirstResponder(tableView) if !hasAtLeastOneSelectedArticle && articles.count > 0 { - tableView.rs_selectRowAndScrollToVisible(0) + tableView.selectRowAndScrollToVisible(0) } } diff --git a/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift b/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift index 4de8f17af..3ea24e91a 100644 --- a/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift +++ b/Mac/Preferences/Accounts/AccountsPreferencesViewController.swift @@ -155,7 +155,7 @@ private extension AccountsPreferencesViewController { addChild(controller) controller.view.translatesAutoresizingMaskIntoConstraints = false detailView.addSubview(controller.view) - detailView.rs_addFullSizeConstraints(forSubview: controller.view) + detailView.addFullSizeConstraints(forSubview: controller.view) } diff --git a/Mac/Preferences/General/GeneralPrefencesViewController.swift b/Mac/Preferences/General/GeneralPrefencesViewController.swift index 4a47f7ad4..57996a485 100644 --- a/Mac/Preferences/General/GeneralPrefencesViewController.swift +++ b/Mac/Preferences/General/GeneralPrefencesViewController.swift @@ -177,7 +177,7 @@ private struct RSSReader: Hashable { let name = (path as NSString).lastPathComponent self.name = name if name.hasSuffix(".app") { - self.nameMinusAppSuffix = name.rs_string(byStrippingSuffix: ".app", caseSensitive: false) + self.nameMinusAppSuffix = name.stripping(suffix: ".app") } else { self.nameMinusAppSuffix = name diff --git a/Mac/Scriptability/Account+Scriptability.swift b/Mac/Scriptability/Account+Scriptability.swift index 2b2bdac09..7e0a7191f 100644 --- a/Mac/Scriptability/Account+Scriptability.swift +++ b/Mac/Scriptability/Account+Scriptability.swift @@ -150,7 +150,7 @@ class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectConta @objc(opmlRepresentation) var opmlRepresentation:String { - return self.account.OPMLString(indentLevel:0, strictConformance: true) + return self.account.OPMLString(indentLevel:0, allowCustomAttributes: false) } @objc(accountType) @@ -168,6 +168,6 @@ class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectConta case .newsBlur: osType = "NBlr" } - return osType.fourCharCode() + return osType.fourCharCode } } diff --git a/Mac/Scriptability/AppDelegate+Scriptability.swift b/Mac/Scriptability/AppDelegate+Scriptability.swift index 13e1e5e31..5ab14538e 100644 --- a/Mac/Scriptability/AppDelegate+Scriptability.swift +++ b/Mac/Scriptability/AppDelegate+Scriptability.swift @@ -44,8 +44,8 @@ extension AppDelegate : AppDelegateAppleEvents { return } - let normalizedURLString = urlString.rs_normalizedURL() - if !normalizedURLString.rs_stringMayBeURL() { + let normalizedURLString = urlString.normalizedURL + if !normalizedURLString.mayBeURL { return } diff --git a/Mac/Scriptability/Feed+Scriptability.swift b/Mac/Scriptability/Feed+Scriptability.swift index f2ae486e5..faf17ced4 100644 --- a/Mac/Scriptability/Feed+Scriptability.swift +++ b/Mac/Scriptability/Feed+Scriptability.swift @@ -146,7 +146,7 @@ class ScriptableFeed: NSObject, UniqueIdScriptingObject, ScriptingObjectContaine @objc(opmlRepresentation) var opmlRepresentation:String { - return self.feed.OPMLString(indentLevel:0, strictConformance: true) + return self.feed.OPMLString(indentLevel:0, allowCustomAttributes: false) } // MARK: --- scriptable elements --- diff --git a/Mac/Scriptability/Folder+Scriptability.swift b/Mac/Scriptability/Folder+Scriptability.swift index 8f522513c..f438f9cca 100644 --- a/Mac/Scriptability/Folder+Scriptability.swift +++ b/Mac/Scriptability/Folder+Scriptability.swift @@ -101,7 +101,7 @@ class ScriptableFolder: NSObject, UniqueIdScriptingObject, ScriptingObjectContai @objc(opmlRepresentation) var opmlRepresentation:String { - return self.folder.OPMLString(indentLevel:0, strictConformance: true) + return self.folder.OPMLString(indentLevel:0, allowCustomAttributes: false) } } diff --git a/Mac/Scriptability/NSScriptCommand+NetNewsWire.swift b/Mac/Scriptability/NSScriptCommand+NetNewsWire.swift index 6d7db56d3..1cc5e36e5 100644 --- a/Mac/Scriptability/NSScriptCommand+NetNewsWire.swift +++ b/Mac/Scriptability/NSScriptCommand+NetNewsWire.swift @@ -22,7 +22,7 @@ extension NSScriptCommand { func isCreateCommand(forClass whatClass:String) -> Bool { guard let arguments = self.arguments else {return false} guard let newObjectClass = arguments["ObjectClass"] as? Int else {return false} - guard (newObjectClass.fourCharCode() == whatClass.fourCharCode()) else {return false} + guard (newObjectClass.fourCharCode == whatClass.fourCharCode) else {return false} return true } @@ -36,12 +36,12 @@ extension NSScriptCommand { print("insertionLocation : \(insertionLocationDescriptor)") // insertion location can be a typeObjectSpecifier, e.g. 'in account "Acct"' // or a typeInsertionLocation, e.g. 'at end of folder " - if (insertionLocationDescriptor.descriptorType == "insl".fourCharCode()) { - descriptorToConsider = insertionLocationDescriptor.forKeyword("kobj".fourCharCode()) - } else if ( insertionLocationDescriptor.descriptorType == "obj ".fourCharCode()) { + if (insertionLocationDescriptor.descriptorType == "insl".fourCharCode) { + descriptorToConsider = insertionLocationDescriptor.forKeyword("kobj".fourCharCode) + } else if ( insertionLocationDescriptor.descriptorType == "obj ".fourCharCode) { descriptorToConsider = insertionLocationDescriptor } - } else if let subjectDescriptor = appleEvent.attributeDescriptor(forKeyword:"subj".fourCharCode()) { + } else if let subjectDescriptor = appleEvent.attributeDescriptor(forKeyword:"subj".fourCharCode) { descriptorToConsider = subjectDescriptor } diff --git a/Shared/Article Rendering/ArticleRenderer.swift b/Shared/Article Rendering/ArticleRenderer.swift index 3bf7569ab..6ddd6299b 100644 --- a/Shared/Article Rendering/ArticleRenderer.swift +++ b/Shared/Article Rendering/ArticleRenderer.swift @@ -48,7 +48,7 @@ struct ArticleRenderer { private extension ArticleRenderer { private var articleHTML: String { - let body = RSMacroProcessor.renderedText(withTemplate: template(), substitutions: substitutions(), macroStart: "[[", macroEnd: "]]") + let body = try! MacroProcessor.renderedText(withTemplate: template(), substitutions: substitutions()) return renderHTML(withBody: body) } diff --git a/Shared/ArticleStyles/ArticleStyle.swift b/Shared/ArticleStyles/ArticleStyle.swift index 3f6898ff5..868745c9b 100644 --- a/Shared/ArticleStyles/ArticleStyle.swift +++ b/Shared/ArticleStyles/ArticleStyle.swift @@ -37,7 +37,7 @@ struct ArticleStyle: Equatable { self.path = path - let isFolder = FileManager.default.rs_fileIsFolder(path) + let isFolder = FileManager.default.isFolder(atPath: path) if isFolder { diff --git a/Shared/ArticleStyles/ArticleStylesManager.swift b/Shared/ArticleStyles/ArticleStylesManager.swift index 7bd161c1c..c7d45f981 100644 --- a/Shared/ArticleStyles/ArticleStylesManager.swift +++ b/Shared/ArticleStyles/ArticleStylesManager.swift @@ -24,7 +24,7 @@ private let styleSuffixes = [styleSuffix, nnwStyleSuffix, cssStyleSuffix]; final class ArticleStylesManager { static let shared = ArticleStylesManager() - private let folderPath = RSDataSubfolder(nil, stylesFolderName)! + private let folderPath = Platform.dataSubfolder(forApplication: nil, folderName: stylesFolderName)! var currentStyleName: String { get { @@ -133,7 +133,7 @@ final class ArticleStylesManager { private func allStylePaths(_ folder: String) -> [String] { - let filepaths = FileManager.default.rs_filepaths(inFolder: folder) + let filepaths = FileManager.default.filePaths(inFolder: folder)! return filepaths.filter { fileAtPathIsStyle($0) } } @@ -154,7 +154,7 @@ private func filenameWithStyleSuffixRemoved(_ filename: String) -> String { for oneSuffix in styleSuffixes { if filename.hasSuffix(oneSuffix) { - return (filename as NSString).rs_string(byStrippingSuffix: oneSuffix, caseSensitive: false) + return filename.stripping(suffix: oneSuffix) } } diff --git a/Shared/Commands/SendToMarsEditCommand.swift b/Shared/Commands/SendToMarsEditCommand.swift index 3a9fd33b2..47ae923f2 100644 --- a/Shared/Commands/SendToMarsEditCommand.swift +++ b/Shared/Commands/SendToMarsEditCommand.swift @@ -57,7 +57,7 @@ private extension SendToMarsEditCommand { let body = article.contentHTML ?? article.contentText ?? article.summary let authorName = article.authors?.first?.name - let sender = SendToBlogEditorApp(targetDesciptor: targetDescriptor, title: article.title, body: body, summary: article.summary, link: article.externalURL, permalink: article.url, subject: nil, creator: authorName, commentsURL: nil, guid: article.uniqueID, sourceName: article.feed?.nameForDisplay, sourceHomeURL: article.feed?.homePageURL, sourceFeedURL: article.feed?.url) + let sender = SendToBlogEditorApp(targetDescriptor: targetDescriptor, title: article.title, body: body, summary: article.summary, link: article.externalURL, permalink: article.url, subject: nil, creator: authorName, commentsURL: nil, guid: article.uniqueID, sourceName: article.feed?.nameForDisplay, sourceHomeURL: article.feed?.homePageURL, sourceFeedURL: article.feed?.url) let _ = sender.send() } diff --git a/Shared/Exporters/OPMLExporter.swift b/Shared/Exporters/OPMLExporter.swift index 75dde22d5..c4927fb54 100644 --- a/Shared/Exporters/OPMLExporter.swift +++ b/Shared/Exporters/OPMLExporter.swift @@ -14,7 +14,7 @@ struct OPMLExporter { static func OPMLString(with account: Account, title: String) -> String { - let escapedTitle = title.rs_stringByEscapingSpecialXMLCharacters() + let escapedTitle = title.escapingSpecialXMLCharacters let openingText = """ @@ -27,7 +27,7 @@ struct OPMLExporter { """ - let middleText = account.OPMLString(indentLevel: 0, strictConformance: true) + let middleText = account.OPMLString(indentLevel: 0, allowCustomAttributes: false) let closingText = """ diff --git a/Shared/Extensions/RSImage-Extensions.swift b/Shared/Extensions/RSImage-Extensions.swift index a09cafeb7..07be41bb1 100644 --- a/Shared/Extensions/RSImage-Extensions.swift +++ b/Shared/Extensions/RSImage-Extensions.swift @@ -23,7 +23,7 @@ extension RSImage { } static func scaledForAvatar(_ data: Data) -> RSImage? { - let scaledMaxPixelSize = Int(ceil(CGFloat(RSImage.avatarSize) * RSScreen.mainScreenScale)) + let scaledMaxPixelSize = Int(ceil(CGFloat(RSImage.avatarSize) * RSScreen.maxScreenScale)) guard var cgImage = RSImage.scaleImage(data, maxPixelSize: scaledMaxPixelSize) else { return nil } diff --git a/Shared/Favicons/FaviconDownloader.swift b/Shared/Favicons/FaviconDownloader.swift index 916bd3c54..8e804026a 100644 --- a/Shared/Favicons/FaviconDownloader.swift +++ b/Shared/Favicons/FaviconDownloader.swift @@ -93,7 +93,7 @@ final class FaviconDownloader { func favicon(withHomePageURL homePageURL: String) -> RSImage? { - let url = homePageURL.rs_normalizedURL() + let url = homePageURL.normalizedURL if homePageURLsWithNoFaviconURL.contains(url) { return nil } diff --git a/Shared/Favicons/SingleFaviconDownloader.swift b/Shared/Favicons/SingleFaviconDownloader.swift index 8058a0a73..91faa0c12 100644 --- a/Shared/Favicons/SingleFaviconDownloader.swift +++ b/Shared/Favicons/SingleFaviconDownloader.swift @@ -34,7 +34,7 @@ final class SingleFaviconDownloader { private let queue: DispatchQueue private var diskKey: String { - return (faviconURL as NSString).rs_md5Hash() + return faviconURL.md5String } init(faviconURL: String, homePageURL: String?, diskCache: BinaryDiskCache, queue: DispatchQueue) { @@ -102,7 +102,7 @@ private extension SingleFaviconDownloader { queue.async { if let data = self.diskCache[self.diskKey], !data.isEmpty { - RSImage.rs_image(with: data, imageResultBlock: callback) + RSImage.image(with: data, imageResultBlock: callback) return } @@ -137,7 +137,7 @@ private extension SingleFaviconDownloader { if let data = data, !data.isEmpty, let response = response, response.statusIsOK, error == nil { self.saveToDisk(data) - RSImage.rs_image(with: data, imageResultBlock: callback) + RSImage.image(with: data, imageResultBlock: callback) return } diff --git a/Shared/Images/ImageDownloader.swift b/Shared/Images/ImageDownloader.swift index 299aba887..08d930a34 100644 --- a/Shared/Images/ImageDownloader.swift +++ b/Shared/Images/ImageDownloader.swift @@ -128,7 +128,7 @@ private extension ImageDownloader { func diskKey(_ url: String) -> String { - return (url as NSString).rs_md5Hash() + return url.md5String } func postImageDidBecomeAvailableNotification(_ url: String) { diff --git a/Shared/Timeline/TimelineStringFormatter.swift b/Shared/Timeline/TimelineStringFormatter.swift index 067d5542c..0b2aaf37a 100644 --- a/Shared/Timeline/TimelineStringFormatter.swift +++ b/Shared/Timeline/TimelineStringFormatter.swift @@ -65,8 +65,8 @@ struct TimelineStringFormatter { s = s.replacingOccurrences(of: "\r", with: "") s = s.replacingOccurrences(of: "\t", with: "") s = s.rsparser_stringByDecodingHTMLEntities() - s = s.rs_stringByTrimmingWhitespace() - s = s.rs_stringWithCollapsedWhitespace() + s = s.trimmingWhitespace + s = s.collapsingWhitespace let maxLength = 1000 if s.count < maxLength { @@ -89,9 +89,9 @@ struct TimelineStringFormatter { return cachedBody } var s = body.rsparser_stringByDecodingHTMLEntities() - s = s.rs_string(byStrippingHTML: 150) - s = s.rs_stringByTrimmingWhitespace() - s = s.rs_stringWithCollapsedWhitespace() + s = s.strippingHTML(maxCharacters: 150) + s = s.trimmingWhitespace + s = s.collapsingWhitespace if s == "Comments" { // Hacker News. s = "" } @@ -100,7 +100,7 @@ struct TimelineStringFormatter { } static func dateString(_ date: Date) -> String { - if NSCalendar.rs_dateIsToday(date) { + if Calendar.dateIsToday(date) { return timeFormatter.string(from: date) } return dateFormatter.string(from: date) diff --git a/Tests/NetNewsWireTests/ScriptingTests/NSAppleEventDescriptor+UserRecordFields.swift b/Tests/NetNewsWireTests/ScriptingTests/NSAppleEventDescriptor+UserRecordFields.swift index f65467310..372d9923f 100644 --- a/Tests/NetNewsWireTests/ScriptingTests/NSAppleEventDescriptor+UserRecordFields.swift +++ b/Tests/NetNewsWireTests/ScriptingTests/NSAppleEventDescriptor+UserRecordFields.swift @@ -22,7 +22,7 @@ extension NSAppleEventDescriptor { print ("error: usrfDictionary() expected input to be a record") return [:] } - guard let usrfList = self.forKeyword("usrf".fourCharCode()) else { + guard let usrfList = self.forKeyword("usrf".fourCharCode) else { print ("error: usrfDictionary() couldn't find usrf") return [:] } diff --git a/iOS/Add/AddFeedViewController.swift b/iOS/Add/AddFeedViewController.swift index b2dc3464b..eeacc4300 100644 --- a/iOS/Add/AddFeedViewController.swift +++ b/iOS/Add/AddFeedViewController.swift @@ -70,7 +70,7 @@ class AddFeedViewController: UITableViewController, AddContainerViewControllerCh func add() { let urlString = urlTextField.text ?? "" - let normalizedURLString = (urlString as NSString).rs_normalizedURL() + let normalizedURLString = (urlString as NSString).normalizedURL guard !normalizedURLString.isEmpty, let url = URL(string: normalizedURLString) else { delegate?.processingDidCancel() @@ -121,7 +121,7 @@ class AddFeedViewController: UITableViewController, AddContainerViewControllerCh } @objc func textDidChange(_ note: Notification) { - delegate?.readyToAdd(state: urlTextField.text?.rs_stringMayBeURL() ?? false) + delegate?.readyToAdd(state: urlTextField.text?.mayBeURL ?? false) } override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { diff --git a/submodules/RSCore b/submodules/RSCore index 07ee91394..34e67f8b5 160000 --- a/submodules/RSCore +++ b/submodules/RSCore @@ -1 +1 @@ -Subproject commit 07ee91394d442ba3a2c4cc5b155a0839809b58b7 +Subproject commit 34e67f8b5f566c29b60bbf6d31331334da0711fe