mirror of
https://github.com/mastodon/mastodon-ios.git
synced 2024-12-15 18:29:36 +01:00
17 lines
604 B
Swift
17 lines
604 B
Swift
// Copyright © 2023 Mastodon gGmbH. All rights reserved.
|
|
|
|
import Foundation
|
|
|
|
public extension NSAttributedString {
|
|
convenience init(format: NSAttributedString, args: NSAttributedString...) {
|
|
let mutableNSAttributedString = NSMutableAttributedString(attributedString: format)
|
|
|
|
args.forEach { attributedString in
|
|
let range = NSString(string: mutableNSAttributedString.string).range(of: "%@")
|
|
mutableNSAttributedString.replaceCharacters(in: range, with: attributedString)
|
|
}
|
|
|
|
self.init(attributedString: mutableNSAttributedString)
|
|
}
|
|
}
|