Post

Replies

Boosts

Views

Activity

Crash: Thread 2: "-[NSTaggedPointerString count]: unrecognized selector sent to instance 0xaa672ff3b4678003"
Hello Everyone, I'm still a beginner and don't have that much experience with Swift. I keep getting this error when I want to start my app "Thread 2: "-[NSTaggedPointerString count]: unrecognized selector sent to instance 0xaa672ff3b4678003"" . What can I do about it Please help. Here is my AppDelegate : import UIKit @main class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func updateLocalizedTexts() { // Überprüfen der Spracheinstellung der App und Erstellen des entsprechenden String-Bundles let currentLanguage = Locale.current.languageCode guard let path = Bundle.main.path(forResource: currentLanguage, ofType: "lproj"), let bundle = Bundle(path: path) else { return } // Alle Labels in der App abrufen guard let window = self.window else { return } let allLabels = getAllLabelsInViewHierarchy(view: window) // Aktualisieren der lokalisierten Texte für alle Labels for label in allLabels { if let labelText = label.text { label.text = NSLocalizedString(labelText, tableName: nil, bundle: bundle, value: "", comment: "") } } } func getAllLabelsInViewHierarchy(view: UIView) -> [UILabel] { var labels: [UILabel] = [] // Alle Views in der Ansichtshierarchie abrufen let allViews = getAllViewsInViewHierarchy(view: view) // Filtere die Views nach UILabels und füge sie zur Ergebnisliste hinzu for view in allViews { if let label = view as? UILabel { labels.append(label) } } return labels } func getAllViewsInViewHierarchy(view: UIView) -> [UIView] { var views: [UIView] = [] // Füge die übergebene View zur Ergebnisliste hinzu views.append(view) // Durchlaufe alle Unterviews der übergebenen View (rekursiv) for subview in view.subviews { views += getAllViewsInViewHierarchy(view: subview) } return views } func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. updateLocalizedTexts() return true } // MARK: UISceneSession Lifecycle func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { // Called when a new scene session is being created. // Use this method to select a configuration to create the new scene with. return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) } func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) { // Called when the user discards a scene session. // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. // Use this method to release any resources that were specific to the discarded scenes, as they will not return. } func application(_ application: UIApplication, didChangeStatusBarFrame oldStatusBarFrame: CGRect) { updateLocalizedTexts() } }
1
0
736
Jun ’23