Hello all - firstly, a thanks to all of you in advance for your help.
I tried googling this problem to no avail. The problem is, I create a mutableCopy of an NSArray and assign it to a NSMutableArray, and quickly assign it to something else and then try to release it. The debugger tells me that it stalls on the release, even though I've checked that retainCount = 1. Here's the code for the entire method:
Thank you in advance.
I tried googling this problem to no avail. The problem is, I create a mutableCopy of an NSArray and assign it to a NSMutableArray, and quickly assign it to something else and then try to release it. The debugger tells me that it stalls on the release, even though I've checked that retainCount = 1. Here's the code for the entire method:
Code:
+ (void)setUpChapters {
NSMutableArray *chapters = [NSMutableArray array];
NSMutableArray *componentsFullList = [NSMutableArray array];
[componentsFullList addObject:@"Introduction\\A few brief words\\intro.html\\introduction.a.few.brief.words"];
[componentsFullList addObject:@"Cells\\A quick look at bacteria\\cells.1.html\\bacteria.LUCA.eukaryote.ribosome"];
[componentsFullList addObject:@"\\Testpage\\cells.1.html\\test.delete.me"];
Chapter *chapter = nil;
if (chapter == nil) {
for (NSString *aComponent in componentsFullList) {
NSArray *aComponentsList = [[aComponent componentsSeparatedByString:@"\\"] copy];
NSLog(@"%@",[[NSNumber numberWithInt:[aComponentsList retainCount]] stringValue]); // returns 1
NSArray *componentsList = aComponentsList;
[aComponentsList release]; // here it stalls
chapter = [[Chapter alloc] initWithName:[componentsList objectAtIndex:0]];
[chapters addObject:chapter];
[chapter release];
if ([componentsList objectAtIndex:1]!=NULL) {
Section *section = [[Section alloc] initWithName:[componentsList objectAtIndex:1]];
[chapter addSection:section];
[section release];
}
TextBody *textBody = [[TextBody alloc] initWithHTMLString:[componentsList objectAtIndex:2]];
[chapter addTextBody:textBody];
[textBody release];
// opening the relevant file to parse into keywords
NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
NSURL *bundleBaseURL = [NSURL fileURLWithPath: bundlePath];
NSURL *bundleBaseURLWithFile = [NSURL URLWithString: [componentsList objectAtIndex:2] relativeToURL: bundleBaseURL];
NSError *error = nil;
NSString *totalDataString = [[NSString alloc] initWithContentsOfURL:bundleBaseURLWithFile encoding:NSUTF8StringEncoding error:&error];
NSLog (@"%@", [error localizedDescription]);
NSCharacterSet *splitterCharacters = [NSCharacterSet characterSetWithCharactersInString:@" .,!?@£$%^&*()_+-=[]{}'\"/~±<>"];
NSMutableArray *keywordList = [[totalDataString componentsSeparatedByCharactersInSet:splitterCharacters] mutableCopy];
for (NSString *individual in keywordList) {
Keywords *keyword = [[Keywords alloc] initWithString:individual];
[chapter addKeywords:keyword];
[keyword release];
}
[keywordList autorelease];
}
}
for (Chapter *aChapter in chapters) {
chapter = aChapter;
}
knownChapters = chapters;
}
Thank you in advance.