2011-08-10 7 views
0

왜 내 textfiled tovalue를 비교할 수 없습니까? 모든haw UITextFiled와 NSString을 비교하십시오.

-(void)testPass:(id)sender 
{ 
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *documentsDirectory = [paths objectAtIndex:0]; 
    NSString *path = [documentsDirectory stringByAppendingPathComponent:@"Info.plist"]; 
    NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path]; 

    NSString *value; 
    value = [dict valueForKey:@"Password"]; 





    if ([value isEqualToString:password.text]) { 

     res = [[XMLTestViewController alloc] initWithNibName:@"XMLTestViewController" bundle:nil]; 
     res.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 
     [self.view addSubview:res.view]; 
    } 
    else { 


     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"IAA" 
                 message:@"Wrong Password" delegate:self cancelButtonTitle:@"Cancel" 
               otherButtonTitles:@"OK", nil]; 


     [alert show]; 
     [alert release]; 
    } 

} 
+0

아무 freind도 idea ????? –

답변

0

첫째, 당신은 NSDictionaryobjectForKey: 대신 KVC의 valueForKey: 사전 콘텐츠에 액세스하는 데 사용합니다.

둘째, password.text이 올바른 값을 반환 했습니까?

+0

예 올바른 값을 반환하고 NSDictionary를 사용합니다 * dict –

+0

도와주세요. 해결책이 없습니다. –

0
-(void)testPass:(id)sender 
    { 
     NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
     NSString *documentsDirectory = [paths objectAtIndex:0]; 
     NSString *path = [documentsDirectory stringByAppendingPathComponent:@"Info.plist"]; 
     NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path]; 

     NSString *value; 
     value = [dict valueForKey:@"Password"]; 

    //to test the values in console 
    NSLog(@"Value; %@", value); 
    NSLog(@"PWordText: %@", password.text); 



     if ([value isEqualToString:password.text]) { 

      res = [[XMLTestViewController alloc] initWithNibName:@"XMLTestViewController" bundle:nil]; 
      res.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 
      [self.view addSubview:res.view]; 
     } 
     else { 


      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"IAA" 
                  message:@"Wrong Password" delegate:self cancelButtonTitle:@"Cancel" 
                otherButtonTitles:@"OK", nil]; 


      [alert show]; 
      [alert release]; 
     } 

} 

그런 다음 콘솔에 값이 표시되는지 확인합니다.

+0

2011-08-10 11 : 05 : 42.887 XMLTest [55877 : 207] 값; pol 2011-08-10 11 : 05 : 42.887 XMLTest [55877 : 207] PWordText : pol –

+0

예 채팅의 코임 인스턴트 메시 –

+0

누구에게 해결책이 있으십니까? –

관련 문제