Trouble with NSCollectionView

  • Greetings Everybody,

    I'm writing an application that reads in a text file containing a
    number of individual messages.  The messages are delimited by the pipe
    "|" character, and I'm trying to index the data inbetween the
    delimiters so that it can be searchable and reportable.  I'm using
    Core Data for this.  My managed object model is something like this:

    Entity: File
    - has a 1 to many relationship with the Message entity.

    Entity: Message
    - has a 1 to many relationship with the Field entity.

    Entity: Field
    - has a "value" property of type String.

    I've written a method that reads in the text from a file, parses out
    the individual messages, and then within each message, parses out each
    field - all the while inserting this information into the managed
    object context.  My method is pretty fast.  I can index a file
    containing 162 messages in about 2.5 seconds.  This performance is
    acceptable for my needs.

    Now I'm trying to integrate an NSCollectionView into my application.
    Each view in the NSCollectionView contains a NSTextView containing the
    text of each message in a selected file.  The NSCollectionView's
    "Content" binding is bound to an Array Controller that holds every
    open file.  So when the user selects a new open file, the
    NSCollectionView updates accordingly by displaying that file's
    messages.  This all works fine, but the problem is that with the
    NSCollectionView bound to the Array Controller, the performance is
    horrible!  My CPU usage is at 100% and my application's memory usage
    runs off the chart!  I can't seem to figure out what the problem is
    here.  I know the problem isn't within my function that performs the
    indexing b/c this works just fine when the NSCollectionView is not
    hooked up.

    Anybody have any clue what I'm doing wrong here?  The NSCollectionView
    is a new class and unfortunately there isn't a lot of documentation on
    it just yet.  Thanks in advance!
  • On Jan 17, 2008 8:39 AM, Carter R. Harrison <carterharrison...> wrote:
    > My CPU usage is at 100% and my application's memory usage
    > runs off the chart!  I can't seem to figure out what the problem is
    > here.  I know the problem isn't within my function that performs the
    > indexing b/c this works just fine when the NSCollectionView is not
    > hooked up.

    Spin Control and Shark (/Developer/Applications/Performance Tools) are
    your friends.  They'll tell you what's actually going on, rather than
    just hazarding a guess.

    --Kyle Sluder
  • > Spin Control and Shark (/Developer/Applications/Performance Tools)
    > are your friends.  They'll tell you what's actually going on, rather
    > than just hazarding a guess.

      I'd suggest Instruments since you're already on Leopard (evidenced
    by NSCollectionView). Take the time to figure it out - it's well worth
    the effort.

    --
    I.S.
  • Thanks for the suggestions.  I loaded up Spin Control and could see
    that the NSCollectionView was constantly attempting to refresh itself
    as I inserted more records into the managed object context.  The
    solution was to create a new NSMutableSet, and add the new records
    into that set.  When I was done adding records, I took the
    NSMutableSet and used setValue:forKey: to update the one to many
    relationship between the File NSManagedObject and the Message
    NSManagedObjects.  Thanks guys.

    On Jan 17, 2008, at 9:34 AM, I. Savant wrote:

    >> Spin Control and Shark (/Developer/Applications/Performance Tools)
    >> are your friends.  They'll tell you what's actually going on,
    >> rather than just hazarding a guess.
    >
    > I'd suggest Instruments since you're already on Leopard (evidenced
    > by NSCollectionView). Take the time to figure it out - it's well
    > worth the effort.
    >
    > --
    > I.S.
    >
    >
    >
previous month january 2008 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today