Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8099401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:24:11+00:00 2026-06-05T22:24:11+00:00

I am trying to implement code to create an account for my app. So

  • 0

I am trying to implement code to create an account for my app. So far I think I have a good understanding of grabbing the data from textfields are storing it in the Core Data database, but I am not sure how I can store the pin the user creates in the keychain for the app. I followed this tutorial which creates a class called Account which I think is a subclass of AccountBase. The Account.m file has a method declaration of:

- (void)setPassword:(NSString*)aPassword

Now I’m pretty sure this is the method I want to use to set the “pin” for my application. I am not sure how I would apply to my ViewControllerCreate.m file. The entire method looks like this:

- (void)setPassword:(NSString*)aPassword 
{
 if (self.username) [KeychainHelper setPassword:aPassword forKey:self.username];

}

So far I have this code in my ViewControllerCreate.m file:

- (IBAction)createAccount:(id)sender {

// hide keyboard when login button is pressed
[_createUserTextField resignFirstResponder];



// check if create textfields are empty - WRONG

[self checkTextFieldCharLength];

// check if boolean is true / false
if([self checkTextFieldEmpty] == TRUE ) // empty text fields
{
    NSLog(@"Please fill in text fields");
}

else {
    NSLog(@"Thanks for filling out the text fields.");
    // Core Data - retrieve values from text fields and store in database.
    NSManagedObject *newAccount;
    newAccount = [NSEntityDescription insertNewObjectForEntityForName:@"Account" inManagedObjectContext:_managedObjectContext];
    [newAccount setValue:_createUserTextField forKey:@"username"];
    [newAccount setValue:_createEmailTextField forKey:@"email"];
    [newAccount setValue:_createPhoneNumber forKey:@"phoneNumber"];

    // TODO store pin in keychain


    _createUserTextField.text = @"";
    _createEmailTextField.text = @"";
    _createPhoneNumber.text = @"";
    NSError *error;
    [_managedObjectContext save:&error];
    [_createAccountSuccess setHidden:NO];
    NSLog(@"Succefully created account.");
}
}

Anyone know how I would go about storing the inputted pin into the keychain when the “create” button is pressed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T22:24:12+00:00Added an answer on June 5, 2026 at 10:24 pm

    Well I kind of came up with a solution thanks to the help of @Faded in chat.stackoverflow.com. The revised code is below:

    // method to pull text from text fields and store in keychain and account database
    
    - (IBAction)createAccount:(id)sender {
    
    [self checkTextFieldCharLength];
    
    // check if create textfields are empty, check if boolean is true / false
    if([self checkTextFieldEmpty] == TRUE ) // empty text fields
    {
        NSLog(@"Please fill in text fields");
    }
    
    else {
        NSLog(@"Thanks for filling out the text fields.");
        // Core Data - retrieve values from text fields and store in database.
        Account *newAccount;
        newAccount = [NSEntityDescription insertNewObjectForEntityForName:@"Account" inManagedObjectContext:_managedObjectContext];
        [newAccount setValue:_createUserTextField.text forKey:@"username"];
        [newAccount setValue:_createEmailTextField.text forKey:@"email"];
        [newAccount setValue:_createPhoneNumber.text forKey:@"phoneNumber"];
    
        // TODO store pin in keychain
        [newAccount setPassword:_createPinTextField.text];
        NSLog(@"Pin saved is %@", [newAccount password]);
    
    
        _createUserTextField.text = @"";
        _createEmailTextField.text = @"";
        _createPhoneNumber.text = @"";
        _createPinTextField.text = @"";
        NSError *error;
        [_managedObjectContext save:&error];
        [_createAccountSuccess setHidden:NO];
        NSLog(@"Succefully created account.");
    }
    

    }

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

pstrjds, From the code you have provided I am trying to implement that code
I am trying to create a simple 3-D app for android that will have
I have a basic MVC 2 beta app where I am trying to implement
I'm trying to implement some code that will create the headers and footers on
I am trying to implement Camera application in android,and i got some code from
I am trying to implement Bidirectional Mapping with Fluent NHibernate Mapping. Code snippet from
I'm trying to implement AES encryption in my application. I have the following code
I have implement the following code to create a SSL server socket. public void
I'm trying to implement the sample code to this article from 2002 (I know..),
I'm trying to implement the code from this tutorial: This is the managed bean:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.