• 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
Re: MutableArray and TableView Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MutableArray and TableView Question


  • Subject: Re: MutableArray and TableView Question
  • From: Conrad Shultz <email@hidden>
  • Date: Tue, 19 Oct 2010 11:29:16 -0700

On my phone so I haven't ran any test code; first thoughts are below. I might see other issues when sitting at a large screen.

-Conrad

On Oct 18, 2010, at 23:02, Chris Share <email@hidden> wrote:

> Here's the coder that I'm using:

Are you sure you copied and pasted? I can't believe that inputTablereloadData (without a space) would compile, let alone run.

> // Clear the input array.
> [inputArray removeAllObjects];
>

Assuming that inputArray is in fact an NSMutableArray (not just cast as such) this should work.

>  // Get an array containing the full filenames of all
> // files and directories selected.
> 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.:

for (NSString *fileName in files) {}

> NSString* fileName = [files objectAtIndex:i];

It strikes me that here is where you are explicitly calling [NSArray objectAtIndex:], which I am pretty sure internally uses the corresponding core foundation call that errors out on you. Are you sure you don't have a typo and are referencing inputArray instead of files? (This is why my comment at the beginning was important.)
>
> When I run this code I get the following error:
>
> *** -[NSCFArray objectAtIndex:]: index (0) beyond bounds (0)
>
> 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)?

--
Conrad Shultz
www.synthetiqsolutions.com_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: MutableArray and TableView Question
      • From: Andy Lee <email@hidden>
References: 
 >MutableArray and TableView Question (From: Chris Share <email@hidden>)

  • Prev by Date: MutableArray and TableView Question
  • Next by Date: Re: MutableArray and TableView Question
  • Previous by thread: MutableArray and TableView Question
  • Next by thread: Re: MutableArray and TableView Question
  • Index(es):
    • Date
    • Thread