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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:36:46+00:00 2026-06-08T12:36:46+00:00

I want to create an iphone application which uses Core Data. As i understood,

  • 0

I want to create an iphone application which uses Core Data.
As i understood, only master-detail application template gives me an option to use Core Data. But it creates table view.

What i want to use is view controller not table view controller.
I couldnt use core data with single view application template..

Which way should I follow to overcome this issue?

Thanks.

  • 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-08T12:36:47+00:00Added an answer on June 8, 2026 at 12:36 pm

    You should realize that CoreData is a framework that is not bound to any UIKit components like UITableView. You can freely use it in any sort of an application. All you have to do is to create your singleton class that manages CoreData operations and add CoreData.framework to your project.

    Here is my DataAccessLayer template:

    DataAccessLayer.h

    #import <Foundation/Foundation.h>
    #import <CoreData/CoreData.h>
    @interface DataAccessLayer : NSObject
    
    @property (strong, nonatomic) NSManagedObjectContext *managedObjectContext;
    @property (strong, nonatomic) NSManagedObjectModel *managedObjectModel;
    @property (strong, nonatomic) NSPersistentStoreCoordinator *storeCoordinator;
    
    + (DataAccessLayer *)sharedInstance;
    - (void)saveContext;
    
    @end
    

    DataAccessLayer.m

    #import "DataAccessLayer.h"
    @interface DataAccessLayer ()
    - (NSURL *)applicationDocumentsDirectory;
    @end
    
    @implementation DataAccessLayer
    @synthesize storeCoordinator;
    @synthesize managedObjectModel;
    @synthesize managedObjectContext;
    
    + (DataAccessLayer *)sharedInstance {
      __strong static DataAccessLayer *sharedInstance = nil;
      static dispatch_once_t onceToken;
      dispatch_once(&onceToken, ^{
        sharedInstance = [[DataAccessLayer alloc] init];
        sharedInstance.storeCoordinator = [sharedInstance persistentStoreCoordinator];
        sharedInstance.managedObjectContext = [sharedInstance managedObjectContext];
      });
      return sharedInstance;
    }
    
    #pragma mark - Core Data
    
    - (void)saveContext {
      @synchronized(self) {
        NSError *error = nil;
        if (managedObjectContext != nil)
        {
          if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error])
          {
            NSLog(@"error: %@", error.userInfo);
            /*
             Replace this implementation with code to handle the error appropriately.
    
             abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. If it is not possible to recover from the error, display an alert panel that instructs the user to quit the application by pressing the Home button.
             */
            NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Oops!"
                                                            message:@"Something has gone terribly wrong! You need to reinstall the app in order for it to work properly."
                                                           delegate:nil
                                                  cancelButtonTitle:@"Close."
                                                  otherButtonTitles:nil, nil];
            [alert show];
          } 
        }
      }
    }
    
    #pragma mark Core Data stack
    
    /**
     Returns the managed object context for the application.
     If the context doesn't already exist, it is created and bound to the persistent store coordinator for the application.
     */
    - (NSManagedObjectContext *)managedObjectContext {
      if (managedObjectContext != nil)
      {
        return managedObjectContext;
      }
    
      if (storeCoordinator != nil)
      {
        managedObjectContext = [[NSManagedObjectContext alloc] init];
        [managedObjectContext setPersistentStoreCoordinator:storeCoordinator];
      }
      return managedObjectContext;
    }
    
    /**
     Returns the managed object model for the application.
     If the model doesn't already exist, it is created from the application's model.
     */
    - (NSManagedObjectModel *)managedObjectModel {
      if (managedObjectModel != nil)
      {
        return managedObjectModel;
      }
      NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"DataModel" withExtension:@"momd"];
      managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];    
      return managedObjectModel;
    }
    
    /**
     Returns the persistent store coordinator for the application.
     If the coordinator doesn't already exist, it is created and the application's store added to it.
     */
    - (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
      if (storeCoordinator != nil)
      {
        return storeCoordinator;
      }
    
      NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"words_db.sqlite"];
    
      NSError *error = nil;
      storeCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
      if (![storeCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error])
      {
        /*
         Replace this implementation with code to handle the error appropriately.
    
         abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. If it is not possible to recover from the error, display an alert panel that instructs the user to quit the application by pressing the Home button.
    
         Typical reasons for an error here include:
         * The persistent store is not accessible;
         * The schema for the persistent store is incompatible with current managed object model.
         Check the error message to determine what the actual problem was.
    
    
         If the persistent store is not accessible, there is typically something wrong with the file path. Often, a file URL is pointing into the application's resources directory instead of a writeable directory.
    
         If you encounter schema incompatibility errors during development, you can reduce their frequency by:
         * Simply deleting the existing store:
         [[NSFileManager defaultManager] removeItemAtURL:storeURL error:nil]
    
         * Performing automatic lightweight migration by passing the following dictionary as the options parameter: 
         [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
    
         Lightweight migration will only work for a limited set of schema changes; consult "Core Data Model Versioning and Data Migration Programming Guide" for details.
    
         */
        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Oops!"
                                                        message:@"Something has gone terribly wrong! You need to reinstall the app in order for it to work properly."
                                                       delegate:nil
                                              cancelButtonTitle:@"Close."
                                              otherButtonTitles:nil, nil];
        [alert show];
      }    
    
      return storeCoordinator;
    }
    
    #pragma mark Application's Documents directory
    
    /**
     Returns the URL to the application's Documents directory.
     */
    - (NSURL *)applicationDocumentsDirectory {
      return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
    }
    
    
    @end
    

    You will also have to create an .xcdatamodeld file in order to create your Data Model objects. And replace the name here with appropriate

      NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"DataModel" withExtension:@"momd"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I m new in iphone..I create Application in which I maintain data About Income
i want to create a application which sync my iPhone contacts to my server
I am new in iPhone development. I want to create one application in which
I am a new iPhone Application developer. I want to create an application which
I want to create an (game based) iPhone application which sends your GPS location
I want to create chat application in iPhone. Are there any framework(s) which support
I want to create an iPhone application which will display notification that an incoming
I have seen the Contacts in iPhone Simulator. I want to create an application
I want to create an iPhone app which makes calls to a web service.
I am trying to create an iPhone application which in some point connects to

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.