Re: Core Data Memory issue on loading a saved file
Re: Core Data Memory issue on loading a saved file
- Subject: Re: Core Data Memory issue on loading a saved file
- From: "Andrew R. Kinnie" <email@hidden>
- Date: Fri, 30 Mar 2007 18:51:57 -0400
Sure, here is the code from the init method in myDocument:
- (id)init
{
self = [super init];
if (self != nil) {
// initialization code
myArray = [[NSArray arrayWithObjects:@"lowest", @"low", @"medium",
@"high",
@"highest"] retain];
NSLog(@"myArray is %@", myArray);
}
return self;
}
I previously didn't retain the created array, and added it because I
guessed that was a problem. However, adding it appears to have had
no effect at all.
On Mar 30, 2007, Dave Fernandes wrote:
From: Dave Fernandes <email@hidden>
Subject: Re: Core Data Memory issue on loading a saved file
To: Cocoa-Dev Developer <email@hidden>
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
Can you post the code for the init method? It sounds like maybe
something isn't being retained that should be retained.
On Mar 30, 2007, at 2:25 PM, Andrew Kinnie wrote:
I have a document-based Core Data app that contains an entity with
an attribute set to be an int16 in the data model.
I can set the value via the UI using bindings, and save it, but
when I load that file back into the app, it crashes with an
EXC_BAD_ACCESS error on the initialization of the array.
Currently, I have that attribute set by a popup which is bound to
an array in myDocument. The array is an array of NSString objects,
and the indices are the numbers I want to associate with those
strings.
In other words:
I have an NSArray which is declared in the myDocument header, and
initialized in the myDocument -init method.
I have an NSArrayController that has its contentArray binding bound
to that array.
I have the popUpButton's content bound to this NSArrayController
(This works, the NSStrings appear in the popup).
I also have the selectedIndex bound to the entity's attribute,
because I want the index to be the number stored in the entity's
attribute.
(This also appears to work because when I change it and save it as
an xml file, the saved file contains the proper number in the
appropriate attribute)
However, when I load, it crashes in the init method of myDocument.
There is nothing else in the init: method that was not there by
default, other than creating the array.
I have no idea what is causing this, as I don't think I've violated
any of the memory rules for Core Data apps. The bindings may be
questionable, but they seemed to work. I have been trying to
resolve this for several days and reading various docs and
debugging hints, but I don't seem to be any closer.
Any insight would be appreciated.
Andrew
PS: I asked about this before, but less clearly, so I am re-
posting without the extraneous details.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden