Просмотр исходного кода

Extract WordLimit into its own file to fix Xcode scope resolution.

Moving the enum out of the String extension file restores reliable indexing and clears the WordLimit compile errors across ViewModels.

Co-authored-by: Cursor <cursoragent@cursor.com>
AhtashamShahzad1 1 месяц назад
Родитель
Сommit
6199d7d4ec
2 измененных файлов с 22 добавлено и 21 удалено
  1. 0 21
      gramora/Utilities/String+WordCount.swift
  2. 22 0
      gramora/Utilities/WordLimit.swift

+ 0 - 21
gramora/Utilities/String+WordCount.swift

@@ -1,26 +1,5 @@
 import Foundation
 import Foundation
 
 
-enum WordLimit {
-    static func message(maxWords: Int) -> String {
-        "Maximum \(maxWords) words allowed."
-    }
-
-    static func apply(_ text: String, maxWords: Int) -> (text: String, exceeded: Bool) {
-        guard text.wordCount > maxWords else { return (text, false) }
-        return (text.truncated(toMaxWords: maxWords), true)
-    }
-
-    static func applyImported(
-        _ text: String,
-        maxWords: Int,
-        setError: (String?) -> Void
-    ) -> String {
-        let (limited, exceeded) = apply(text, maxWords: maxWords)
-        setError(exceeded ? message(maxWords: maxWords) : nil)
-        return limited
-    }
-}
-
 extension String {
 extension String {
     var wordCount: Int {
     var wordCount: Int {
         let trimmed = trimmingCharacters(in: .whitespacesAndNewlines)
         let trimmed = trimmingCharacters(in: .whitespacesAndNewlines)

+ 22 - 0
gramora/Utilities/WordLimit.swift

@@ -0,0 +1,22 @@
+import Foundation
+
+enum WordLimit {
+    static func message(maxWords: Int) -> String {
+        "Maximum \(maxWords) words allowed."
+    }
+
+    static func apply(_ text: String, maxWords: Int) -> (text: String, exceeded: Bool) {
+        guard text.wordCount > maxWords else { return (text, false) }
+        return (text.truncated(toMaxWords: maxWords), true)
+    }
+
+    static func applyImported(
+        _ text: String,
+        maxWords: Int,
+        setError: (String?) -> Void
+    ) -> String {
+        let (limited, exceeded) = apply(text, maxWords: maxWords)
+        setError(exceeded ? message(maxWords: maxWords) : nil)
+        return limited
+    }
+}