0

That's my code

int indiceCorrente=0; int differenza=delegate.reader.feedItems.count;

while(variable!=0){
switch(variable){

case 1: ----
case 2: ----


default: { 

                NSMutableIndexSet *add=[[[NSMutableIndexSet alloc]init] autorelease];
                [add addIndex:indiceCorrente];
                [add addIndex:indiceCorrente+1];
                [add addIndex:indiceCorrente+2];
                [self aggiungiElementoArrayLettura:add];





                //[page addObject:@"makeLayout3"];
                NSMutableArray *pagina=[[NSMutableArray alloc]init];

                indiceCorrente=indiceCorrente+1;
                [pagina addObject:indiceCorrente]; <------ EXC_BAD_ACCESS WHY????
                indiceCorrente=indiceCorrente+1;
                [pagina addObject:indiceCorrente];
                indiceCorrente=indiceCorrente+1;
                [pagina addObject:indiceCorrente];


                [pages addObject:pagina];

            }
}
}
2
  • what is aggiungiElementoArrayLettura Commented Jul 14, 2013 at 22:11
  • You need to an object, not an int, which is a primitive type. See questions such as this: stackoverflow.com/questions/10486519/… Commented Jul 14, 2013 at 22:11

1 Answer 1

2

you can't add primitive types (int, float, double...) into Foundation collection classes. You can only add objects. When you try to add an int, it is being cast into a pointer (id) and the array is trying to retain that. Try wrapping your ints in an NSNumber. That would look like

[pagina addObject:@(indiceCorrente)];

or

[pagina addObject:[NSNumber numberWithInt:indiceCorrente]];
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.