소스 검색

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 개월 전
부모
커밋
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
 
-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 {
     var wordCount: Int {
         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
+    }
+}