Ho un NSMutableArray (_theListOfAllQuestions)
che sto popolando con i numeri da un file. Poi ho confrontato gli oggetti di quell'array con qNr (NSString)
e ho ricevuto un errore. Ho persino lanciato l'array su un altro NSString
, _checkQuestions
, solo per essere sicuro di confrontare NSStrings
. Ho provato a usare l'oggetto per confrontare anche.Perché ottengo un errore nel confrontare NSString? (- [__ NSCFNumber isEqualToString:]: selettore non riconosciuto inviato all'istanza)
-(void)read_A_Question:(NSString *)qNr {
NSLog(@"read_A_Question: %@", qNr);
int counter = 0;
for (NSString *item in _theListOfAllQuestions) {
NSLog(@"item: %@", item);
_checkQuestions = _theListOfAllQuestions[counter]; //_checkQuestion = NSString
NSLog(@"_checkQuestions: %@", _checkQuestions);
if ([_checkQuestions isEqualToString:qNr]) {
NSLog(@">>HIT<<");
exit(0); //Just for the testing
}
counter++;
}
Quando si esegue questo codice ottengo il seguente NSLog
:
read_A_Question: 421
item: 1193
_checkQuestions: 1193
... ed errori:
-[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x9246d80 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x9246d80'
Credo che ho ancora il confronto NSString
con un numero di qualche sorta ma a me sembra che sto confrontando NSString
vs NSString
?
Potrei davvero bisogno di aiuto qui per 1) capire il problema, 2) risolvere il problema?
Ebbene '_checkQuestions', in almeno un caso, è un 'NSNumber' e non un' NSString' . Cosa si trova esattamente in '_theListOfAllQuestions'? E come viene popolato? –