ios - If-statement with NSMutableString hasprefix phone number (Beginner) -


hey don't succeed make functional if-statement nsstring

j abmultivaluegetcount(phones).

i've 3 cases : j=0, j=1, j=2...

i when j = 0 or 1 or 2, doesn't take number prefix 02...

if j has number prefix 06, save number.

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

i tried make code, doesn't work, don't know 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;             }         } } 

this seems problem (it should != instead):

if ([phonenumber length] == 0) 

to make code simpler - should same result:

if (j >= 0 && j < 3 && ![phonenumber hasprefix:@"02"] && (![person.number hasprefix:@"06"] || [phonenumber hasprefix:@"06"])) {     person.number = phonenumber; } 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -