On Oct 19, 2010, at 2:29 PM, Conrad Shultz wrote:
> Are you sure you copied and pasted? I can't believe that inputTablereloadData 
> (without a space) would compile, let alone run. 

I assumed there was some peculiarity of Chris's emailer that causes the space 
to get deleted, as seems to have happened with "[NSOpenPanelopenPanel]", but 
it's a fair question.  If we aren't seeing the exact code verbatim, we could 
all be off on a wild goose chase.  I myself don't see anything wrong.

>> NSArray* files = [openDlg filenames];
>> // Loop through all the files and process them.
>> for(i = 0; i < [files count]; i++) {
> 
> You should use fast enumeration if possible, e.g.:

Even simpler would be:

    [inputArray setArray:[openDlg filenames]];

>> I assume that it's the [inputArray removeAllObjects] that's causing the 
>> problem 
>> (?) If I remove this line, the code works but the filenames keep getting 
>> added 
>> to the array which isn't what I want.
>> 
> This is a lot of supposition. Do you have a backtrace you can inspect ("bt" 
> in gdb)?

Yup!  This seems like a perfect situation for basic debugging techniques.  As 
Matt suggested, break on the exception and see what line of your code is 
causing the problem.  It'll be a line of code where you're assuming x y z, and 
one of your assumptions will be untrue, and the fun question will be "Why?"

I love puzzles like this because it seems "impossible."  From looking at the 
posted code, assuming the table view data source methods do the obvious thing, 
and from the fact that it doesn't crash when the removeAllObjects is removed, 
it "should" absolutely work.  (By the way, Chris should have posted the table 
view data source methods too.)

Look at the backtrace and inspect the state of your program variables when the 
exception is raised.  At that moment inputArray has zero length and yet it 
*can't* have zero length.

Personally I would add some NSLogs, like putting this in various strategic 
spots:

    NSLog(@"inputArray (%p) -- contents %@", inputArray, inputArray);

The %p will cause the address of inputArray to be printed, so you can confirm 
you're dealing with the same instance at all times and it hasn't been replaced 
behind your back.

--Andy

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to