FROM : Oliver Cameron
DATE : Wed Oct 13 20:22:30 2004
Oops. one little code change, this line:
File *fileDocument = [[File alloc] initWithParent:folderGroup
withName:[filePath lastPathComponent] withPath:filePath
withContents:[NSString stringWithContentsOfFile:filePath] isGroup:NO
isDocument:YES];
Should be:
File *fileDocument = [[File alloc] initWithParent:rootProject
withName:[filePath lastPathComponent] withPath:filePath
withContents:[NSString stringWithContentsOfFile:filePath] isGroup:NO
isDocument:YES];
With the parent name changing.
Sorry about that :-)
Oliver
On 13 Oct 2004, at 19:11, Oliver Cameron wrote:
> Hey guys,
>
> I'm having trouble of thinking out a way to put files/folders from a
> preset folder into a NSOutlineView, basically I can currently get a
> folders contents and put it all into a NSOutlineView, but the objects
> in the outline view are just single files and are not organized like
> it should be, in correct folders. Here is my current code:
>
> - (void)processFolder:(NSString *)path
> {
> NSFileManager *fileManager = [NSFileManager defaultManager];
> NSDirectoryEnumerator *fileEnumerator = [fileManager
> enumeratorAtPath:path];
> NSString *fileString;
> while (fileString = [fileEnumerator nextObject])
> {
> NSString *filePath = [path stringByAppendingString:fileString];
> NSFileWrapper *fileWrapper = [[NSFileWrapper alloc]
> initWithPath:filePath];
> if ([fileWrapper isDirectory])
> {
> File *folderGroup = [[File alloc] initWithParent:rootProject
> withName:[filePath lastPathComponent] withPath:filePath
> withContents:nil isGroup:YES isDocument:NO];
> [rootProject addFile:folderGroup];
> [self processFolder:filePath];
> }
> else
> {
> File *fileDocument = [[File alloc] initWithParent:folderGroup
> withName:[filePath lastPathComponent] withPath:filePath
> withContents:[NSString stringWithContentsOfFile:filePath] isGroup:NO
> isDocument:YES];
> [rootProject addFile:fileDocument];
> }
> }
> [outlineView reloadData];
> }
>
> Basically what happens is I just get the path of the folder, use a
> NSDirectoryEnumerator to go through it and get all its contents, I
> then use NSFileWrapper to tell if a file is a folder, and if it is,
> add a File object as a folder, if its not, add it as a normal
> document. So I end up with a 1 level NSOutlineView with all the files
> and folders in a list. Ideally I'd like the correct files to be in the
> correct folders, but I just can't think of how to go about this. The
> parent of the file and where its added depends on where its added in
> the Outline View. I have seen the OutlineView.pbproj project, but its
> not what I would like. It basically does it all from inside the
> equivalent of my File class, but I'd like to keep the File class
> flexible, and I'd prefer to do all the processing in the controller
> class.
>
> Any ideas appreciated,
> Oliver
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (<email_removed>)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
DATE : Wed Oct 13 20:22:30 2004
Oops. one little code change, this line:
File *fileDocument = [[File alloc] initWithParent:folderGroup
withName:[filePath lastPathComponent] withPath:filePath
withContents:[NSString stringWithContentsOfFile:filePath] isGroup:NO
isDocument:YES];
Should be:
File *fileDocument = [[File alloc] initWithParent:rootProject
withName:[filePath lastPathComponent] withPath:filePath
withContents:[NSString stringWithContentsOfFile:filePath] isGroup:NO
isDocument:YES];
With the parent name changing.
Sorry about that :-)
Oliver
On 13 Oct 2004, at 19:11, Oliver Cameron wrote:
> Hey guys,
>
> I'm having trouble of thinking out a way to put files/folders from a
> preset folder into a NSOutlineView, basically I can currently get a
> folders contents and put it all into a NSOutlineView, but the objects
> in the outline view are just single files and are not organized like
> it should be, in correct folders. Here is my current code:
>
> - (void)processFolder:(NSString *)path
> {
> NSFileManager *fileManager = [NSFileManager defaultManager];
> NSDirectoryEnumerator *fileEnumerator = [fileManager
> enumeratorAtPath:path];
> NSString *fileString;
> while (fileString = [fileEnumerator nextObject])
> {
> NSString *filePath = [path stringByAppendingString:fileString];
> NSFileWrapper *fileWrapper = [[NSFileWrapper alloc]
> initWithPath:filePath];
> if ([fileWrapper isDirectory])
> {
> File *folderGroup = [[File alloc] initWithParent:rootProject
> withName:[filePath lastPathComponent] withPath:filePath
> withContents:nil isGroup:YES isDocument:NO];
> [rootProject addFile:folderGroup];
> [self processFolder:filePath];
> }
> else
> {
> File *fileDocument = [[File alloc] initWithParent:folderGroup
> withName:[filePath lastPathComponent] withPath:filePath
> withContents:[NSString stringWithContentsOfFile:filePath] isGroup:NO
> isDocument:YES];
> [rootProject addFile:fileDocument];
> }
> }
> [outlineView reloadData];
> }
>
> Basically what happens is I just get the path of the folder, use a
> NSDirectoryEnumerator to go through it and get all its contents, I
> then use NSFileWrapper to tell if a file is a folder, and if it is,
> add a File object as a folder, if its not, add it as a normal
> document. So I end up with a 1 level NSOutlineView with all the files
> and folders in a list. Ideally I'd like the correct files to be in the
> correct folders, but I just can't think of how to go about this. The
> parent of the file and where its added depends on where its added in
> the Outline View. I have seen the OutlineView.pbproj project, but its
> not what I would like. It basically does it all from inside the
> equivalent of my File class, but I'd like to keep the File class
> flexible, and I'd prefer to do all the processing in the controller
> class.
>
> Any ideas appreciated,
> Oliver
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list (<email_removed>)
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
| Related mails | Author | Date |
|---|---|---|
| Oliver Cameron | Oct 13, 20:11 | |
| Oliver Cameron | Oct 13, 20:22 |






Cocoa mail archive

