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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:29:45+00:00 2026-05-20T13:29:45+00:00

dear developer i want make an image from an offscreen view. when i start

  • 0

dear developer i want make an image from an offscreen view.

when i start my app the first view is the RootViewController and everthing
works fine.

when i go to an other view and make this.

RootViewController *root = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];

UIImage *screenShot = [self imageWithView: root.tableView];

(UIImage *) imageWithView:(UIView *)view

{

UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, [[UIScreen mainScreen] scale]); 
    [view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return img;

}

The app crash in the “imageWithView:(UIView *)view” function at the line
[view.layer renderInContext:UIGraphicsGetCurrentContext()];

the log says
Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘+entityForName: could not locate an NSManagedObjectModel for entity name ‘ListItem”

and this happen in the rootviewcontroller on the line

NSEntityDescription *entity = [NSEntityDescription entityForName:@"ListItem" inManagedObjectContext:self.managedObjectContext];

somebody an idea?

  • 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-05-20T13:29:46+00:00Added an answer on May 20, 2026 at 1:29 pm

    As Rog said there is probably no context. Here is the code that create the one correctly:

    -(NSManagedObjectContext*) managedContext {
        @synchronized( self ) {
            if( !_managedObjectContext) {
                _managedObjectContext = [[NSManagedObjectContext alloc] init];
                [_managedObjectContext setPersistentStoreCoordinator: [VIDataManager sharedManager].persistentStoreCoordinator];
            }
        }
    
        return _managedObjectContext;
    }
    
    -(NSPersistentStoreCoordinator*) persistentStoreCoordinator {
        @synchronized( self ) {
            if( !_persistentStoreCoordinator ) {
                NSLog(@"init _persistentStoreCoordinator");
                NSError *error = nil;
                _persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: self.managedObjectModel];
    
                if( ![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL: databaseURL() options:nil error: &error] ) {
                }
            }
        }
    
        return _persistentStoreCoordinator;    
    }
    
    -(NSManagedObjectModel*) managedObjectModel {
        @synchronized( self ) {
            if( !_managedObjectModel ) {
                NSLog(@"init _managedObjectModel");
                NSURL* modelURL = [[NSBundle mainBundle] URLForResource:@"Datamodel" withExtension:@"mom"];
                _managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL: modelURL];
            }
        }
    
        return _managedObjectModel;
    
    }
    

    And in @interface you have to declare 3 ivars and properties:

        NSManagedObjectContext*             _managedObjectContext;
        NSManagedObjectModel*               _managedObjectModel;
        NSPersistentStoreCoordinator*       _persistentStoreCoordinator;
    
    @property(nonatomic, readonly) NSManagedObjectContext*          managedContext;
    @property(nonatomic, readonly) NSManagedObjectModel*            managedObjectModel;
    @property(nonatomic, readonly) NSPersistentStoreCoordinator*    persistentStoreCoordinator;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Dear friends,I want to extract text 平均3.6 星 from this code segment excerpted from
Dear Friends from Stackoverflow, Please help me with a problem that i'm having when
Dear all devexpress winform gurus:) My way is simple. First, i create a bindinglist:
Dear iPhone Developers, I am writing a Navigation based iPhone application. I want to
hi my dear friends : i am asp.net web developer and never work with
hello dear developers. first of all - sorry for being the newbie.. i am
Dear fellow developer, for some reason updates for 1720 records takes around 15 seconds
I want to register as an IPhone developer(company;s account) so i followed all steps
Dear all. Today, I start to learn iOS. I don't know what tool I
I currently want to make my project accessible not only via back-end code (C#,

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.