- (IBAction) executes normally, but then crushes.
- (IBAction) executes normally, but then crushes.
- Subject: - (IBAction) executes normally, but then crushes.
- From: Тимофей Даньшин <email@hidden>
- Date: Thu, 19 Mar 2009 23:55:57 +0300
Hello.
I have got a method that is an IBAction, and it works quite all right,
it reaches its final curly bracket, but then the whole application
crushes for some reason. But the words [Session started... etc] in the
log appear about three lines before the phrase "Finished adding to the
DB", which is written by the last line of code in that method. I.e.,
if i feed the following to my app: "It first empties the cell's title
and
asks it to draw.", the last lines of the log look as follows:
2009-03-19 23:47:28.204 Untitled[16510:10b] The splitString is 'dra'
[Session started at 2009-03-19 23:47:28 +0300.]
2009-03-19 23:47:28.207 Untitled[16510:10b] The splitString is 'raw'
2009-03-19 23:47:28.211 Untitled[16510:10b] The splitString is 'aw.'
2009-03-19 23:47:28.214 Untitled[16510:10b] Finished Adding to DB;
Loading program into debugger…
GNU gdb 6.3.50-20050815 (Apple version gdb-962) (Sat Jul 26 08:14:40
UTC 2008)
What can possibly go wrong there?
The idea behind this method is to have a string in the textView split
by sentences (which is done by the SentenceSplitter, which was tested
and works well), then write each sentence to the database, split that
sentence into sequences of three chars each (by ThreeCharSplitter,
which also was tested), and write them into a different table in the
same db. As i said earlier, everything works fine, everything gets
added to the db as expected. The only unexpected thing is the crush at
the end.
Here is the method:
- (IBAction) dbit: (id) sender {
SentenceSplitter *ss = [[SentenceSplitter alloc] initWithString:
[[tview textStorage] string]];
DB *db = [[DB alloc] initWithPath:@"somePath"];
NSString *sentence;
NSString *splitString;
ThreeCharSplitter *sp;
for (int i = 0; i < [ss length]; i++) {
@try {
sentence = [ss nextSentence];
if (sentence == nil || sentence.length == 0) {
continue;
}
sp = [[ThreeCharSplitter alloc] initWithString:sentence];
int a = [db writeToDB: sentence];
NSLog(@"Last id is %d, sentence: %@", a, sentence);
for (int i = 0; i < sp.length; i++) {
splitString = [sp next];
NSLog(@"The splitString is '%@'", splitString);
if ( a != 0 ) {
[db writeCharsToDB:splitString withSentenceId:a];
}
}
[sp release];
} @catch (NSException *e) {
NSLog(@"EXCEPTION: %@", e);
}
}
[db release];
[ss release];
NSLog (@"Finished Adding to DB;");
}
Thank you for your attention._______________________________________________
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