Removes use of deprecated String.characters property

This commit is contained in:
Riley Testut 2017-10-12 14:43:36 -07:00
parent fb5036acf8
commit 356d843a9b
6 changed files with 9 additions and 9 deletions

@ -1 +1 @@
Subproject commit 1d74f647aaeec653a3ab55d7c06a0b3c0dc95069 Subproject commit c1443afa0ede9100a0cc64a9d985636b6384af01

View File

@ -340,7 +340,7 @@ private extension GameCollectionViewController
func rename(_ game: Game, with name: String) func rename(_ game: Game, with name: String)
{ {
guard name.characters.count > 0 else { return } guard name.count > 0 else { return }
DatabaseManager.shared.performBackgroundTask { (context) in DatabaseManager.shared.performBackgroundTask { (context) in
let game = context.object(with: game.objectID) as! Game let game = context.object(with: game.objectID) as! Game
@ -401,7 +401,7 @@ private extension GameCollectionViewController
@objc func textFieldTextDidChange(_ textField: UITextField) @objc func textFieldTextDidChange(_ textField: UITextField)
{ {
let text = textField.text ?? "" let text = textField.text ?? ""
self._renameAction?.isEnabled = text.characters.count > 0 self._renameAction?.isEnabled = text.count > 0
} }
@objc func handleLongPressGesture(_ gestureRecognizer: UILongPressGestureRecognizer) @objc func handleLongPressGesture(_ gestureRecognizer: UILongPressGestureRecognizer)

View File

@ -49,7 +49,7 @@ extension CheatTextView
{ {
let characterWidth = ("A" as NSString).size(withAttributes: [.font: font]).width let characterWidth = ("A" as NSString).size(withAttributes: [.font: font]).width
let width = characterWidth * CGFloat(format.format.characters.count) let width = characterWidth * CGFloat(format.format.count)
self.textContainer.size = CGSize(width: width, height: 0) self.textContainer.size = CGSize(width: width, height: 0)
} }
} }
@ -134,7 +134,7 @@ extension CheatTextView: NSLayoutManagerDelegate
if let prefix = attributedFormat.attributes(at: characterIndex, effectiveRange: nil)[.cheatPrefix] as? String if let prefix = attributedFormat.attributes(at: characterIndex, effectiveRange: nil)[.cheatPrefix] as? String
{ {
// If there is a prefix string, we insert the glyphs (and associated properties/character indexes) first // If there is a prefix string, we insert the glyphs (and associated properties/character indexes) first
let prefixCount = prefix.characters.count let prefixCount = prefix.count
for j in 0 ..< prefixCount for j in 0 ..< prefixCount
{ {

View File

@ -51,7 +51,7 @@ struct CheatValidator
// Remove newline characters (code should already be formatted) // Remove newline characters (code should already be formatted)
let sanitizedCode = (cheat.code as NSString).replacingOccurrences(of: "\n", with: "") let sanitizedCode = (cheat.code as NSString).replacingOccurrences(of: "\n", with: "")
if sanitizedCode.characters.count % self.format.format.characters.count != 0 if sanitizedCode.count % self.format.format.count != 0
{ {
throw Error.invalidCode throw Error.invalidCode
} }

View File

@ -132,7 +132,7 @@ extension EditCheatViewController
// Update UI // Update UI
if name.characters.count == 0 if name.count == 0
{ {
self.title = NSLocalizedString("Cheat", comment: "") self.title = NSLocalizedString("Cheat", comment: "")
} }
@ -224,7 +224,7 @@ private extension EditCheatViewController
@IBAction func updateCheatName(_ sender: UITextField) @IBAction func updateCheatName(_ sender: UITextField)
{ {
var title = sender.text ?? "" var title = sender.text ?? ""
if title.characters.count == 0 if title.count == 0
{ {
title = NSLocalizedString("Cheat", comment: "") title = NSLocalizedString("Cheat", comment: "")
} }

View File

@ -377,7 +377,7 @@ private extension SaveStatesViewController
func rename(_ saveState: SaveState, with name: String?) func rename(_ saveState: SaveState, with name: String?)
{ {
var name = name var name = name
if (name ?? "").characters.count == 0 if (name ?? "").count == 0
{ {
// When text is nil, we know to show the timestamp instead // When text is nil, we know to show the timestamp instead
name = nil name = nil