• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
What may be wrong?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Help! Open File always returns YES
  • Next by Date: Displaying an alert while selection is changing in a NSOutlineView
  • Previous by thread: Re: Help! Open File always returns YES
  • Next by thread: Displaying an alert while selection is changing in a NSOutlineView
  • Index(es):
    • Date
    • Thread