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

  • SEARCH
  • Home
  • 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 8161909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:35:54+00:00 2026-06-06T18:35:54+00:00

Alright, I’ll try and make this as simple as possible. I’m trying to create

  • 0

Alright, I’ll try and make this as simple as possible. I’m trying to create a user account from my create user scene in my iPhone application, and write now I can’t figure out why I can’t save the pin the user creates into the / a keychain. I have a button labeled create account and I would like to save the data the user inputs into a keychain and my account entity in the core data DB. This is the code I have when the user presses the create account button.

- (IBAction)createAccount:(id)sender {

[self checkTextFieldCharLength];

// check if create textfields are empty, check if boolean is YES / NO
if([self checkTextFieldEmpty] == YES ) // 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;
    Account *pinAccount;
    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
    [pinAccount setPassword:_createPinTextField.text];
    NSLog(@"Pin saved is %@", [newAccount password]);


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

    // Segue to user home screen

}
}

The account.h and account.m files:

Account.h

#import "AccountBase.h"

@interface Account : AccountBase {

}

// nonatomic - don't worry about multithreading

@property (nonatomic, assign) NSString *password;

- (void)setPassword:(NSString*)aPassword;

@end

Account.m

#import "Account.h"
#import "KeychainHelper.h"

@implementation Account

- (NSString*)password 
{
if (self.username)
    return [KeychainHelper getPasswordForKey:self.username];
return nil;
}

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


}
- (void)prepareForDeletion
{
if (self.username) [KeychainHelper removePasswordForKey:self.username];
 }
@end

KeychainHelper.h http://pastie.org/4124627
KeychainHelper.m http://pastie.org/4124631

I am getting the following error:

2012-06-21 00:33:24.915 KegCop[41960:fb03] -[NSManagedObject password]: unrecognized selector sent to instance 0x6b83940
2012-06-21 00:33:24.916 KegCop[41960:fb03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSManagedObject password]: unrecognized selector sent to instance 0x6b83940'
*** First throw call stack:
(0x134a022 0x1733cd6 0x134bcbd 0x12b0ed0 0x12b0cb2 0x5df3 0x134be99 0x38614e 0x3860e6 0x42cade 0x42cfa7 0x42c266 0x647a1a 0x131e99e 0x12b5640 0x12814c6 0x1280d84 0x1280c9b 0x1f837d8 0x1f8388a 0x383626 0x1d0d 0x1c75 0x1)
terminate called throwing an exception(lldb)

  • 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-06T18:35:57+00:00Added an answer on June 6, 2026 at 6:35 pm

    I was able to create an account and store it in the Core Data DB, and was also able to store the pin entered by the user in the keychain with the following code.

    // 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]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, I'll try and make this brief as possible. I wanted to a UIToolbar
Alright, I am trying to accomplish this: When a user clicks a button that
Alright I don't see why this isnt working. It seems pretty simple. Here is
Alright I created some custom classes for my project sourced from this tutorial ,
Alright, here I am again trying to write code from scratch and I can't
Alright, so I've been trying to implement a simple binary search tree that uses
Alright so i have been working on this Dynamic load of a spinner from
Alright. I have several queries <?php // Make a MySQL Connection mysql_connect(mm.hostname.net, user, pass)
Alright guys, this should be a very simple request. I'd like to run a
Alright, I'm trying to figure out why I can't understand how to do this

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.