SOLVED Re: SIGTRAP on adding object to mutable array
SOLVED Re: SIGTRAP on adding object to mutable array
- Subject: SOLVED Re: SIGTRAP on adding object to mutable array
- From: Daniel Child <email@hidden>
- Date: Tue, 11 Sep 2007 18:40:56 -0400
That's what I would have expected, but during debugging,
wordObjects had an address and was listed as having 0 objects.
However, your suggesting I look these over helped me uncover the error.
I had declared the instance variables to be of one type and actually
allocated memory for another type. Amazingly, XCode did not catch
this or even
generate a warning.
Thanks.
/************************************************************
CONSTRUCTORS */
+ (WordParser *) sharedParser
{
if (wordParser == nil) {
wordParser = [[WordParser alloc] init];
}
return wordParser;
}
/***************************************************** WORD PARSER'S
INIT */
- (id) init
{
if (self = [super init]) {
[self setSyllables: [[NSMutableDictionary alloc] init]]; //
SOURCE OF ERROR
[self setWordCandidates: [[NSMutableDictionary alloc] init]]; //
SOURCE OF ERROR
}
return self;
}
/************************************************************ SETTERS */
- (void) setWordCandidates: (NSMutableArray *) wc
{
if (wc != wordCandidates) {
[wordCandidates release];
wordCandidates = [wc mutableCopy];
}
}
Up to the critical point in the code, I have had no occasion to
dealloc the shared parser, and
since the instance variable wordCandidates is not autoreleased, it
should have stuck around.
On Sep 11, 2007, at 5:37 PM, Shawn Erickson wrote:
On 9/11/07, Daniel Child <email@hidden> wrote:
- (void) addCandidate: (NSString *) c
{
[[self wordCandidates] addObject: c]; // wordCandidates
is an
NSMutableArray ivar
// SIGTRAP HERE
// ALSO TRIED [wordCandidates addObject: c];
// DO I NEED TO COPY OR RETAIN HERE?
}
It sounds like wordCandidates in pointing at an object that no longer
exits. So what code touches wordCandidates? How is that object
created? etc.
-Shawn
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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