views:

23

answers:

0

Hi, I am having difficulties with some logic. What I am trying to do is I have a nsmutablearray which I want to do a check with an object. If i have selected multiple creditcards in a particular view i store that card details name is my nsmutablearray called filteredCard. Then I have objects of companies which has one or more creditcards link to it. Now if the creditcard selected is same has the company I want to store the details in nsmutablearray of results. I can do if one card is seleted, but if more then a card how can i check. The following is my code.

    for (CreditCard *obj in validCreditCard)
{
    if ([obj.checked isEqualToNumber:[NSNumber numberWithBool:YES]] ){
        [filteredCard addObject:obj.name];  

        for(Company *temp in actualData)
        {
            if(temp.bankcard1){
                BOOL isExist = [self isEqualcheck:temp.bankcard1]; 
                if(!isExist){
                    [results addObject:temp];

                }

            }
            if(temp.bankCard2){
                BOOL isExist = [self isEqualcheck:temp.bankCard2]; 
                if(!isExist){
                    [results addObject:temp];

                }
            }

            if(temp.bankCard3){
                BOOL isExist = [self isEqualcheck:temp.bankCard3]; 
                if(!isExist){
                    [results addObject:temp];
                }
            }

        }
    }

}

//this is how i check the card with the company
- (BOOL)isEqualcheck:(NSString*) name
{
    for(NSString *obj in filteredCard){
    if ([obj isEqualToString:name]) {
        return NO;
    }
}
return YES;

}

Kindly advice me cause when i try doing this

if(temp.bankcard1 && temp.bankcard2) 

it doesn't work.

Your advice will be very helpful. Thank you in advance.