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
Post a Comment