What may be wrong?
What may be wrong?
- Subject: What may be wrong?
- From: Lukasz Kuczborski <email@hidden>
- Date: Fri, 15 Mar 2002 15:40:07 +0100
i have two methods:
- (IBAction)setupFind:(id)sender
{
[NSThread detachNewThreadSelector:@selector(Find) toTarget:self
withObject:sender];
}
- (void)Find
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int all;
NSDirectoryEnumerator *direnum = [[NSFileManager defaultManager]
enumeratorAtPath:[path stringValue]];
NSString *fullPath = [path stringValue];
[self update];
[find setState:YES];
[progress setIndeterminate:YES];
[progress startAnimation:self];
if(!(pname = [direnum nextObject]))
{
NSRunAlertPanel(@"No path selected!",@"Please choose path, and then
continue.", @"Silly Me ;-)", nil, nil);
}
else
{
fileSpecs = [[NSMutableArray alloc] init];
}
while(pname = [direnum nextObject])
{
NSRange aRange;
NSString *big = [[NSString alloc] initWithString:[pname
lastPathComponent]];
NSString *small = [toSearch stringValue];
aRange = [big rangeOfString:small
options:(NSCaseInsensitiveSearch)];
if(aRange.location >= 0 && aRange.length > 0)
{
Table *nowy = [[Table alloc] init];
[nowy setIconCell:[[NSWorkspace sharedWorkspace]
iconForFile:[fullPath stringByAppendingPathComponent:pname]]];
[nowy setPathToFile:[fullPath
stringByAppendingPathComponent:pname]];
[nowy setFileExtension:[pname pathExtension]];
[nowy setFileName:[pname lastPathComponent]];
[fileSpecs addObject:nowy];
[nowy release];
all = [fileSpecs count];
[found setIntValue:all];
[big release];
[self update];
}
}
all = [fileSpecs count];
[found setIntValue:all];
[find setState:NO];
if(all == 0)
{
[self update];
NSRunAlertPanel(@"No files found!",@"Please try again, it
happens...:)", @"Try Again!", nil, nil);
}
[progress stopAnimation:self];
[progress setIndeterminate:NO];
[pool release];
}
And sometimes my app works very good, but sometimes it hangs...i know that
it must be a problem related with threads, or NSAutoreleasePool...
PLEASE help,
Lukasz
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.