Re: SIGTRAP on adding object to mutable array
Re: SIGTRAP on adding object to mutable array
- Subject: Re: SIGTRAP on adding object to mutable array
- From: Dave Fernandes <email@hidden>
- Date: Tue, 11 Sep 2007 17:34:47 -0400
Where is wordCandidates alloc'd and init'd?
On Sep 11, 2007, at 5:23 PM, Daniel Child wrote:
Hi All,
I am attempting to add an object to an NSMutableArray, and when I
do, I get a SIGTRAP error. I have tried a bunch of different ways
of doing this and can't seem to find the problem. I did almost the
exact same thing in some other code and it worked fine, so I am
totally mystified.
Here is the relevant code. Thanks in advance.
Daniel
(for a structure like this)
@interface WordParser : NSObject
{
NSMutableArray *syllables;
NSMutableArray *wordCandidates;
NSMutableString *currentCandidate;
NSString *head;
NSString *tail;
}
(implementation to follow)
- (NSMutableArray *) deriveCandidatesFromSyllables {
int i, numSyllables, dividingPoint;
NSString *tempHead, *tempTail;
NSMutableString *tempCandidate = [[NSMutableString alloc] init];
numSyllables = [[self syllables] count]; // syllables is an
instance variable conttaining array of syllables
dividingPoint = numSyllables;
for (i = numSyllables; i > 0; i--) {
tempHead = [self getHeadUpToDividingPoint: dividingPoint]; //
THIS WORKS
tempTail = [self getTailAfterDividingPoint: dividingPoint]; //
THIS WORKS
// tempCandidate will be the head + space plus the tail
// ACTUALLY SHOULD ADD IN MORE SOPHISTICATED MANNER
[tempCandidate appendString: tempHead];
[tempCandidate appendString: SPACE];
[tempCandidate appendString: tempTail];
[self setHead: tempHead];
[self setTail: tempTail];
[self setCurrentCandidate: tempCandidate]; // THIS HAS A VALUE
[self addCandidate: tempCandidate]; // SIGTRAP OCCURS HERE
}
[tempCandidate release];
return wordCandidates;
}
- (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?
}
_______________________________________________
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:
40utoronto.ca
This email sent to email@hidden
_______________________________________________
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