dimanche 30 août 2015

If-statement with NSMutableString hasprefix phone number (Beginner)

Hey I don't succeed to make a functional if-statement with my NSString

j is ABMultiValueGetCount(phones).

I've three cases : j=0, j=1, j=2...

I would like that when j = 0 or 1 or 2, that doesn't take number with prefix 02...

if j has number with prefix 06, save this number.

if j has number with other prefix save it, except if number with prefix 06 is already saved.

I tried to make this code, but it doesn't work, I don't know where is my error :

if (j == 0) {
                        if ([phoneNumber hasPrefix:@"02"]){}
                        else if([phoneNumber hasPrefix:@"06"]){
                            person.number = phoneNumber;    }
                        else
                        {
                        if ([phoneNumber length] == 0)
                            {
                                person.number = phoneNumber;
                            }
                }
            }
            if (j == 1) {
                if ([phoneNumber hasPrefix:@"02"]){}
                else if([phoneNumber hasPrefix:@"06"]){
                    person.number = phoneNumber;    }
                else {if ([phoneNumber length] == 0)
                {
                    person.number = phoneNumber;
                }}
            }
            if (j == 2) {
                if ([phoneNumber hasPrefix:@"02"]){}
                else if([phoneNumber hasPrefix:@"06"]){
                    person.number = phoneNumber;    }
                else {if ([phoneNumber length] == 0)
                {
                    person.number = phoneNumber;
                }}
            }

Aucun commentaire:

Enregistrer un commentaire