NSPopUpButton failure after adding file names
NSPopUpButton failure after adding file names
- Subject: NSPopUpButton failure after adding file names
- From: Rick Anderson <email@hidden>
- Date: Thu, 15 May 2003 03:25:58 -0700
I have an NSPopUpButton that I want to populate with the names of files
in a specific directory on launch. I'm calling a function from
awakeFromNib that handles this. The function that I wrote to do this
appears to work (at least, it gets through the code without any
apparent problem, but when it returns to awakeFromNib, the app dies
"due to signal 11 (SIGSEGV)."
I'm not sure what I'm doing that is causing this. I temporarily rewrote
the function and simply added the names of the files directly and it
worked perfectly (I did this wondering if perhaps some character in the
file names was causing problems since some of the names contained
punctuation.) However, when it try to add them by actually enumerating
through the files and adding the file names, then this failure occurs.
And to reiterate: it doesn't happen within the function, but rather
after the function returns.
Here's the function I wrote for adding the file names to the
NSPopUpButton. Is there some subtle problem with what I'm doing here?
- (void)populateTemplateMenu
{
NSDirectoryEnumerator *theDirectory = [[NSFileManager
defaultManager] enumeratorAtPath:@"templates/layouts/"];
NSMutableString *pathname = [[NSMutableString alloc] init];
NSMutableString *fullPath = [[NSMutableString alloc] init];
while (pathname = [theDirectory nextObject])
{
// establish the full path to the file
[fullPath setString:
@"/Users/rick/Development/pf/build/templates/layouts/"];
[fullPath appendString: pathname];
// isFilePackageAtPath requires full path
if ( ([[NSWorkspace
sharedWorkspace]isFilePackageAtPath:fullPath]) ||
([pathname isEqualToString:@".DS_Store"]) )
{
// skip any folders or bundles
[theDirectory skipDescendents];
}
else
{
// use the file name to build the layout menu
[storySectionMenu addItemWithTitle: pathname];
}
}
[theDirectory autorelease];
[pathname autorelease];
[fullPath autorelease];
}
--Rick Anderson
"The only difference between me and a madman
is that I am not mad." -- Salvador Dali
_______________________________________________
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.