I created a Artist/Genre table based on the File table example given in Chapter 5- Extra Columns in Shane Stanley’s book. I’m loading data from a plist. The plist stores artist name and genre and other info. I have two buttons “Rock”, “Blues”. When user clicks a button, data corresponding to that genre is loaded in the table. This part works fine. I then added a NSSearchField described on Page 44 of the book which filters based on Artist Names. The issue is that when I click either the Rock or Blues button when the table is displaying filtered data, the removeObjects method of ArrayController removes only the filtered entries, not all objects . As a result I see duplicate data in my table
here is my code :
property thePlistData : {}
property PLIST_PATH : ""
on awakeFromNib()
        set plistFileString to (path to desktop as string) &  "artist_genre.plist"
        set PLIST_PATH to POSIX path of plistFileString
        set thePlistData to NSMutableDictionary's alloc()'s initWithContentsOfFile_(PLIST_PATH)
   end awakeFromNib
on loadArtists_(sender)
        set tagNumber to sender's tag() as string
        if tagNumber is equal to "1" then
            set artistsGenre to "Rock"
        else
            set artistsGenre to "Blues"
        end if
        -- build list of records
        set tempList to {}
        set theKeys to thePlistData's allKeys() as list
        repeat with key in theKeys
                set theDictObj to thePlistData's valueForKey_(key)
                set genreType to (theDictObj's valueForKey_("theGenre")) as string
                if genreType is equal to artistsGenre then
                    set end of tempList to {theArtist:key,theGenre: genreType}
                end if
        end repeat
        theArtistArrayController's removeObjects:(theArtistArrayController's arrangedObjects())
        theArtistArrayController's addObjects:tempList
    end loadArtists_
Is there a way to handle this issue? Is there another method to remove all objects and not just the filtered objects from the ArrayController?