KVC and Bindings Question

  • I'm trying to implement a simple bookmarks drawer just for fun on an
    app I'm writing.  All I'm wanting is to have a tableView with names
    listed and when you make a selection, I can access the URL that I
    have associated with that name.  Simple bookmark management.
    However, I keep getting an error that I'm not KVC for the key
    "bookmarkName".  Below is my class code, if anyone has any
    suggestions, please shoot away.  I looked at the bindings info for my
    Array Controller (content selection, key being "bookmarkName" and
    other places, like in the bindings for the tableView itself, it looks
    like everything should work.  I guess I'm missing something pretty
    fundamental here.  Thanks for the feedback!

    Matt

    @interface Bookmark : NSObject {
    NSString *bookmarkName;
    NSURL *url;
    }

    -(void)setBookmarkName:(NSString *)aName;
    -(NSString *)bookmarkName;
    -(void)setUrl:(NSURL *)aUrl;
    -(NSURL *)url;

    @end

    @implementation Bookmark

    -(void)setBookmarkName:(NSString *)aName {
    aName = [aName copy];
    [bookmarkName release];
    bookmarkName = aName;
    }

    -(NSString *)bookmarkName {
    return bookmarkName;
    }

    -(void)setUrl:(NSURL *)aUrl {
    aUrl = [aUrl copy];
    [url release];
    url = aUrl;
    }

    -(NSURL *)url {
    return url;
    }

    @end
  • On Oct 27, 2006, at 7:56 PM, Matthew Brewer wrote:

    > However, I keep getting an error that I'm not KVC for the key
    > "bookmarkName".  Below is my class code, if anyone has any
    > suggestions, please shoot away.

    The code you posted appears to be correct. It might be a typo
    somewhere in your nib file.

        - Scott
  • Thanks for pointing me in the right direction, I was having issues
    getting my tableview to display my bookmarks.  I'm not sure what I
    was thinking by using the "editable" bindings for the arraycontroller
    as well as the tableview, but removing those did indeed help get me
    on my way.  Was also able to add quick encoding/decoding for basic
    file saving, makes me really appreciate just how amazing Cocoa is!
previous month october 2006 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