Usando datos de lira, ¿cómo se escribe la rama condicional en el objetivo-c [duplicado]

I have three pictures, A.png, B.png and C.png, which I would like to show it on my tableview accessory area. I have record the category data A, B and C in my Lita database. I wanted to show different pictures for different categories. So I wrote the below code in the cellforrowatindexpath section.

    if (category.table = @"A"){
    accessoryView = A.png
    }else if (category.table = @"B"){
    accessoryView = B.png
    }else{
    accessoryView = C.png}

However, all the picture that shows on accessoryView is A.png. What did I do wrong? How could I fix this to show the pictures' properly.

I will be really appreciate if anyone can help me.

preguntado el 15 de noviembre de 13 a las 08:11

On second thought, it is not a duplicate: Your code asigna a new value with =. -

Thank you very much for the quick help! I had the same problem as the question you have indicated for me. I really appreciate your help. -

1 Respuestas

Did you copy/paste this code fragment ? Cause string comparison are made this way in objective-C :

if ([category.table isEqualToString:@"A"])
{
  // do something
}

Other question : what class is your accessoryView ?

respondido 15 nov., 13:08

Thank you very much for the quick reply. I have fixed my code, and it worked. Thank you very much for your help. - Kenken

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.