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 8162033
In Process

The Archive Base Latest Questions

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

Alright, I am still messing around with Core Data in my iOS project, and

  • 0

Alright, I am still messing around with Core Data in my iOS project, and I think I have a good idea how it works conceptually, but am struggling how I should implement into my project. I created a scene in my Xcode project where I want the user / operator of the software to create a user account, have it stored in the project.

First off let me state I started the project as a single view application and I implemented Core Data into my project by doing the following:

  • linking to the Core Data framework in my project
  • then created another project with Core Data checkbox checked
  • copied / pasted the code in the AppDelegate.h/m files.
  • created file.xcdatamodeld
  • added the following line to the KegCop-Prefix.pch file #import <CoreData/CoreData.h>
  • created an Entity Account, and added the following attributes email phoneNumber username in the file.xcdatamodel

After completing what I found to be the necessary steps, I sought out to find some tutorials on core data. I did manage to find some, but they all seemed to deal with using a UITableViewController The view controller that I am trying to implement Core Data in my project is a UIViewController

Then after learning that one shouldn’t store passwords in a Core Data database I decided to figure out how I was going to store the pin that the user would create. I came across a tutorial that implements Core Data & Keychain’s to store nonsensitive data in the Core Data database and sensitive data in the Keychain. The tutorial can be found here. The tutorial however wasn’t ARC ready so some modification was needed to some of the KeychainHelper.m file. After some help from stackoverflow, the KeychainHelper.m file appears to be ARC ready.

Now after completing the above stated tutorial I had three new classes in my project, AccountBase, Account, and KeychainHelper. My project is building without any errors at the moment \o/ but I want to be able to implement the newly created classes into my project, i.e. actually use them. This is something the tutorial doesn’t discuss. Now keep in mind I’ve been using Xcode almost on a day to day basis for almost a month now so I am still new to a lot of things. And one of those things is how I would implement these new classes into my project.

Basically I want the user to type in a username, pin (twice) email, and a phone number. I want to store the username, email, and phone number in the core data database, and store the pin in the keychain.

How would I use the newly created class file Account in my ViewControllerCreate to retrieve the values the user inputs into the text fields and store them to the Core Data database?

Sorry for such a long post, thought I would just try and make this clear as possible so there wouldn’t be any confusion.

  • 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:37:25+00:00Added an answer on June 6, 2026 at 6:37 pm

    I was able to solve this problem by importing the Account class into the header of the ViewControllerCreate class with the following line of code.

    #import "Account.h"

    I was able to use the ManagedObjectContext through out the various classes / view controllers with the following code

    // Core Data
    
    if (_managedObjectContext == nil)
    {
        _managedObjectContext = [(AppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext];
        NSLog(@"After _managedObjectContext: %@", _managedObjectContext);
    }
    

    I was then able to utilize the Account class in the ViewControllerCreate 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 so I have no idea how to even begin doing this But basically
Alright I've been messing around with this for hours now and I still can't
Alright so I have been looking around (on SO and Google) to see if
Alright, I presented this question on the MSDN forums but have yet to receive
Alright, still working on a science project involving the testing of the speeds of
Alright I am still learning my functions in php but this particular piece of
Alright I know that the .closest() have been discussed before, but I have been
Alright, so I've been doing some poking around, and I realize my problem, but
Alright, I have some data that I need to assign an int type identifier
Alright, this is driving me nuts because my regex is working on Rubular, but

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.