mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
🩹 Fixes memory leaks caused by NSString usage
This commit is contained in:
committed by
Brent Simmons
parent
3739906da9
commit
a9f33643f6
@@ -26,7 +26,7 @@ struct ArticleRenderer {
|
||||
init(name: String) {
|
||||
url = Bundle.main.url(forResource: name, withExtension: "html")!
|
||||
baseURL = url.deletingLastPathComponent()
|
||||
html = try! NSString(contentsOfFile: url.path, encoding: String.Encoding.utf8.rawValue) as String
|
||||
html = try! String(contentsOfFile: url.path, encoding: .utf8)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,13 +180,13 @@ private extension ArticleRenderer {
|
||||
|
||||
static var defaultStyleSheet: String = {
|
||||
let path = Bundle.main.path(forResource: "styleSheet", ofType: "css")!
|
||||
let s = try! NSString(contentsOfFile: path, encoding: String.Encoding.utf8.rawValue)
|
||||
let s = try! String(contentsOfFile: path, encoding: .utf8)
|
||||
return "\n\(s)\n"
|
||||
}()
|
||||
|
||||
static let defaultTemplate: String = {
|
||||
let path = Bundle.main.path(forResource: "template", ofType: "html")!
|
||||
let s = try! NSString(contentsOfFile: path, encoding: String.Encoding.utf8.rawValue)
|
||||
let s = try! String(contentsOfFile: path, encoding: .utf8)
|
||||
return s as String
|
||||
}()
|
||||
|
||||
|
||||
@@ -85,8 +85,9 @@ struct ArticleTheme: Equatable {
|
||||
if !FileManager.default.fileExists(atPath: f) {
|
||||
return nil
|
||||
}
|
||||
|
||||
if let s = try? NSString(contentsOfFile: f, usedEncoding: nil) as String {
|
||||
|
||||
var encoding = String.Encoding.utf8
|
||||
if let s = try? String(contentsOfFile: f, usedEncoding: &encoding) {
|
||||
return s
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user