• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Core Data Based Application Bug?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Core Data Based Application Bug?


  • Subject: Core Data Based Application Bug?
  • From: Colin Cornaby <email@hidden>
  • Date: Thu, 4 Aug 2005 22:37:29 -0700

Hey,

I'm trying to rig up some code to only run when a new document is opened in my Core Data based Application. It is my understanding that I can simply override the init method within the NSPersistantDocument instnace to add code for when a new untitled document is created. However, this code is being run every time a new document is opened in addition to a new document being created. Here is the code:

//  MyDocument.m
//  Catalyst
//
//  Created by Colin Cornaby on 7/28/05.
//  Copyright __MyCompanyName__ 2005 . All rights reserved.

#import "MyDocument.h"
#import <ThemeKit/TKTheme.h>

@implementation MyDocument

- (id)init
{
self = [super init];
if (self != nil) {
//Initialize the theme for the document. A TKTheme is a NSManagedObjectContext subclass
//so we can directly interface to CoreData. We can also set the TKTheme as this persistent
//document's object context.
TKTheme *documentTheme = [[TKTheme alloc] init];
[documentTheme addVariation:@"Untitled Variation"];
[self setManagedObjectContext:documentTheme];
}
return self;
}


- (NSString *)windowNibName
{
    return @"MyDocument";
}

- (void)windowControllerDidLoadNib:(NSWindowController *) windowController
{
[super windowControllerDidLoadNib:windowController];
// user interface preparation code
}


@end

However, the addVariation method is being called every time a document is opened, as a new variation adds itself to the list of variations any time?

When I did a document based app before I think the init method worked as the documentation states, running only when an "Untitled" document is opened. Do I go about this a different way in a Core Data Based Application, or is this actually a bug?


--------------------------- Colin Cornaby - http://gomac.blogspot.com/ Carpe Stellarem - Lead Programmer, ProToys - http://carpestellarem.com Macintosh Specialist - University of Portland - htttp://up.edu

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Core Data Based Application Bug?
      • From: Chris Hanson <email@hidden>
    • Re: Core Data Based Application Bug?
      • From: Charilaos Skiadas <email@hidden>
  • Prev by Date: How turn-off C-run time library memory diagnostics?
  • Next by Date: Re: Core Data Based Application Bug?
  • Previous by thread: Re: How turn-off C-run time library memory diagnostics?
  • Next by thread: Re: Core Data Based Application Bug?
  • Index(es):
    • Date
    • Thread