2009-09-11 7 views
0

LotteryAppDelegate * appDelegate = (LotteryAppDelegate *) [[UIApplication sharedApplication] delegate]; Lotterycheck * check; 두 문자열 비교 문제 ...!

//NSString *trueval; 
BOOL found = NO; 
    NSUInteger f; 
for (f = 0; f < [appDelegate.books count]; f++) { 



    check = [appDelegate.books objectAtIndex:f]; 

    checkthis = [NSString stringWithFormat:@"%@", check.LotteryNumber]; 


    mystring [email protected]"1234567"; //check.LotteryNumber; 
    NSString *finel = checkthis; 
    NSLog(@"Dynamic Value: %@",finel); 
    NSLog(@"Static Value: %@",mystring); 

    if ([mystring isEqualToString:finel]) { 
     found = YES; 
     [self showalert:finel]; 
     break; 

    } 

그 문자열 comapring 없음 "의 경우 ([mystring에 isEqualToString : finel])"을 MyString 정적 값이고 finel 객체가 속하는 것으로 가정 난 클래스 lotterycheck로부터 얻고 값 ..

+0

아마도 이전 질문을 다시 읽지 말고 업데이트해야합니다. – crashmstr

답변

1

인 appDelegate.books가 Book 클래스 인 경우 다음 코드 스 니펫을 사용해보십시오.

BOOL found = NO; 
NSString *mystring = @"1234567"; 

for (Book *book in appDelegate.books) { 

    NSString *checkthis = [NSString stringWithFormat:@"%@", book.LotteryNumber]; 

    if ([mystring isEqualToString checkthis]) { 
     found = YES; 
     [self showalert:checkthis]; 
     break; 

    } 
} 
+0

답장을 보내 주셔서 감사합니다 ... LotteryNumber is string .. –