views:

11

answers:

0

i'm facing a really strange problem here i'm having this method in iphone sdk which all what it have to do is get the next row data from the database and i want to make some validation so the user don't go to -1 row for example.. so i did the code

___________________

-(void)getPageContent:(int)inx{

CryptAppDelegate *appDelegate = (CryptAppDelegate *)[[UIApplication sharedApplication] delegate];

if(inx<0 ){
    inx=0;
}
if (inx > [appDelegate.pages count]) {
    inx =[appDelegate.pages count];
}

    Story *story = (Story *)[appDelegate.pages objectAtIndex:inx];

[page setText:@""]; 
[page setText:story.page];
}

which is work fine at the first glance but if i press the previous button several time it make the (inx) argument come with minus although there is the condition of

if(inx<0 ){ inx=0; } if i pressed several times it gives -3 or whatever the number of pressing i've did to the button it's confusing cause it should be always with 0 after it finish the method. what have i done wrong?