开发者

question on NSSecureTextField & Window management in Objective C

I am lil bit new to objective C. Here is my requirement. I have a small button in my iPad App on pressing it takes me to a config screen. The requirement is I want to make this button secure. Only users with password can proceed to the config screen. If they do not enter the rite password, it should return back the main screen.

So, I though of something like, on clicking the button open a new window and provide a text field where the users enter the password and based on that move to config screen or not.

Can some 开发者_StackOverflow中文版help me with a proper pseudo code for me to try ?

Here is my button,

-(IBAction) goBack 
{
    [self.navigationController popViewControllerAnimated:YES]; 
}


you need single check, compare use entered password with app password if both match then move forward to config screen.else error message.

instructions(not in obj-c)

if userEnterPassword==app.password
    push->configView
else
   msg(error);

some thing like this.

Edit:

You can save password in NSUserDefaults

-(void)setPassCode
{

    NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];

    if (standardUserDefaults) 
    {
        [standardUserDefaults setObject:passCodeTextField.text forKey:@"lock"];
        [standardUserDefaults synchronize];


    } 
}

and these line for checking in a button click

    -(IBAction)checkPassCode
    {
    NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
        NSString *passcode== [standardUserDefaults objectForKey:@"lock"];


    if([passcode isEqualToString:lockTextField.text])
        {   
              Second *obj=[[Second alloc] initWithNibName:@"Second" bundle:nil];
              [self.navigationController pushViewController:obj animated:YES];
              [obj release];
        }
    else
    {
      UIAlertView *confirmAlertView=[[UIAlertView alloc]initWithTitle:@"" message:@"Error" delegate:nil cancelButtonTitle:@"YES" otherButtonTitles:@"NO",nil];
            [confirmAlertView show];
            [confirmAlertView release];

    }
    }

Edit:

.h file

 UITextField *lockTextField;

and make it property with IBOutlet

@property (nonatomic,retain) IBOutlet UITextField *lockTextField;

and in .m synthsize it

@synthesize lockTextField;

and make connection form IB.see the tutorial how to make connection which i suggest you.

now you can access this textField.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜