objective c - looping in iphone -


possible duplicate:
for loop , if statement

hi everyone, have following loop , preeceding if else condition.m using following code.

for (int intprjname=0 ; intprjname<[arrprjname count]  ;intprjname++) {     if ([strselectedprojectname caseinsensitivecompare:[arrprjname objectatindex:intprjname])     {          //some code     }     else     {         //some code     }  } 

suppose strselectedprojectname "aaa"and arrprjname contains "aaa" "bbb" "ccc" .. after first iteration of loop if condition gets true i.e string "aaa" matches string in array list,it should out of loop @ second iteration,i.e should not enter else condition..

add break; command

for (int intprjname=0 ; intprjname<[arrprjname count]  ;intprjname++) {     if ([strselectedprojectname caseinsensitivecompare:[arrprjname objectatindex:intprjname])     {          //some code         break;     }     else     {         //some code     }  } 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -