Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Obj-C: Newbie Needs Advanced Help

Obj-C: Newbie Needs Advanced Help
Thread Tools
Fresh-Faced Recruit
Join Date: Aug 2001
Location: California
Status: Offline
Reply With Quote
Aug 10, 2001, 06:15 AM
 
Hi, I have a cocoa application in the works that will be a file browser, but I hit a major wall. I know the basics of Objective-C, but my C/C++ is bad (I just know syntax, enough to get by). I think that my problem can be solved with a knowledge of C, but am not sure. Here is the code (everything is linked correctly):

Controller.h
--------------
#import <Cocoa/Cocoa.h>

@interface Controller : NSObject

{
IBOutlet id directoryField;
IBOutlet id tableView;
IBOutlet id tableColumn;
NSArray *files;
}
- (IBAction)check id)sender;

@end

--------------
Controller.m
--------------
#import "Controller.h"

@implementation Controller

- (IBAction)check id)sender
{
BOOL isDir;
NSString *path = [directoryField stringValue];
NSFileManager *manager = [NSFileManager defaultManager];
if ([manager fileExistsAtPath ath isDirectory:&isDir] && isDir)
{
files = [manager directoryContentsAtPath ath];
}
[tableView reloadData];
}

- (int)numberOfRowsInTableView NSTableView *)aTableView
{
return [files count];
}

- (id)tableView NSTableView *)aTableView
objectValueForTableColumn NSTableColumn *)aTableColumn
row int)rowIndex
{
return [files objectAtIndex:rowIndex];
}

@end

---------------

During runtime, I get this error: FileBrowser.app has exited due to signal 11 (SIGSEGV).

I have know idea what SIGSEGV is. Sometimes instead of SIGSEGV it is SIGBUS.

Any information on this would be appreciated.

[ 08-10-2001: Message edited by: El Presidente ]
AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH!
     
Fresh-Faced Recruit
Join Date: Aug 2001
Location: California
Status: Offline
Reply With Quote
Aug 10, 2001, 08:28 AM
 
I made two key mistakes:

1) I should have posted this in the Mac OS X section -- duh
2) The array "files" was autoreleased, all I needed to do was add [files retain]

Yay!
AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH!
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 11:10 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2