1
0
mirror of https://github.com/mastodon/mastodon-ios.git synced 2024-12-15 18:29:36 +01:00
mastodon-app-ufficiale-ipho.../MastodonSDK/Sources/MastodonUI/Extension/NSAttributedString+Format.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)
}
}