Question

J'ai eu récemment un accident concernant un sélecteur ne pas être trouvé lorsqu'une notification a été publiée à l'aide NSNotificationCenter. Que peut être la cause de cette erreur?

Je l'ai remarqué qu'il n'y avait pas de code utilisateur appelé après la notification a été publiée, ce qui ne semble pas être un problème du côté de la réception de la notification. Cependant, ce qui pourrait provoquer NSNotificationCenter plantage?

Voici la trace de la pile de l'appel:

0   libSystem.B.dylib               0x00078ac8 __kill + 8
1   libSystem.B.dylib               0x00078ab8 kill + 4
2   libSystem.B.dylib               0x00078aaa raise + 10
3   libSystem.B.dylib               0x0008d03a abort + 50
4   libstdc++.6.dylib               0x00044a20 __gnu_cxx::__verbose_terminate_handler() + 376
5   libobjc.A.dylib                 0x00005958 _objc_terminate + 104
6   libstdc++.6.dylib               0x00042df2 __cxxabiv1::__terminate(void (*)()) + 46
7   libstdc++.6.dylib               0x00042e46 std::terminate() + 10
8   libstdc++.6.dylib               0x00042f16 __cxa_throw + 78
9   libobjc.A.dylib                 0x00004838 objc_exception_throw + 64
10  CoreFoundation                  0x000a167c -[NSObject(NSObject) doesNotRecognizeSelector:] + 96
11  CoreFoundation                  0x000491d2 ___forwarding___ + 502
12  CoreFoundation                  0x00048f88 _CF_forwarding_prep_0 + 40
13  Foundation                      0x000146ac _nsnote_callback + 136
14  CoreFoundation                  0x0002670c __CFXNotificationPost_old + 396
15  CoreFoundation                  0x000263ac _CFXNotificationPostNotification + 112
16  Foundation                      0x0000b014 -[NSNotificationCenter postNotification:] + 132
17  [My Application]                0x000a5ad2 -[PortfolioUpdateOperation main] (PortfolioUpdateOperation.m:37)
18  Foundation                      0x0000e9e8 -[__NSOperationInternal start] + 652
19  Foundation                      0x0000e74c -[NSOperation start] + 16
20  Foundation                      0x00023574 ____startOperations_block_invoke_2 + 40
21  libSystem.B.dylib               0x000d597c _dispatch_call_block_and_release + 12
22  libSystem.B.dylib               0x000d675c _dispatch_worker_thread2 + 120
23  libSystem.B.dylib               0x0007a67a _pthread_wqthread + 258
24  libSystem.B.dylib               0x00073190 start_wqthread + 0
Était-ce utile?

La solution

Très probablement NSNotificationCenter tente d'informer une instance d'objet qui n'existe plus.

En d'autres termes, un objet a été sans désallouée se détacha en tant qu'observateur NSNotificationCenter. Vérifiez votre code pour les cas où un objet lui-même ajoute un observateur NSNotificationCenter mais ne parvient pas à se retirer de NSNotificationCenter.

Autres conseils

On dirait que vous avez ajouté un objet comme un observateur qui ne répond pas au sélecteur que vous avez fourni. Assurez-vous que votre méthode de notification accepte un argument de type NSNotification

Peut-être un chèque à respondsToSelector suivi avec une exploitation forestière du nom de la classe de l'objet etc pourrait vous aider?

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top