Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4241960
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:22:43+00:00 2026-05-21T03:22:43+00:00

I have an ImageView which shows a lock, informing if an opened file is

  • 0

I have an ImageView which shows a lock, informing if an opened file is locked or not. I have 2 images for locked and unlocked cases. I want synchronize the displayed image with boolean value of my object representing an opened file.

To do this I want my ViewController to change the image in my ImageView depending on lock state of object. So both object and ViewController have a property “isLocked”.

How can I synchronize them? It is easy in IB but I don’t know how to do it programmatically. I tried in initialize method of my ViewController to use:

[ViewController bind:@"value" toObject:[ArrayController selection] withKeyPath:@"isLocked" options:nil];

But it doesn’t work. In documentation it is said that I have to expose my binding before using it.

I try to put the following code in initializer method of my object:

[self exposeBinding:@"isLocked"];

But Xcode doesn’t recognize this method.

Does somebody have experience with this kind of bindings establishing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T03:22:43+00:00Added an answer on May 21, 2026 at 3:22 am

    As @nick says, you want Key-Value-Observing.

    [arrayController addObserver:self 
                    forKeyPath:@"selection.isLocked"
                    options:NSKeyValueObservingOptionNew
                    context:@"this_context"]
    

    Then when isLocked changes the -observeValueForKeyPath:ofObject:change:context: method that you have added to your viewController will be called (as long as you only manipulate isLocked in a KVC compliant way).

    The options parameter lets you optionally tweak exactly what conditions will trigger the notification and what data is sent along with the notification. The context parameter is there to help you distinguish between notifications that you registered to receive and notifications your superclass registered to receive. It is optional.

    Bindings seem like they might be useful to keep two values in sync. However, this is not what they do at all.

    Yes, lots of things seem to give the impression that this is what they do, and there isn’t much saying that this isn’t what they do, also lots of people believe that this is what they do – but no, you cannot use them for this.

    Only a handful of classes support bindings (they are listed here) and then, and this is the important bit, those classes only support binding their named bindings, and these bindings are not instance variables. eg NSTextField has a ‘fontFamilyName‘ binding yet NSTextField does not have a ‘fontFamilyName’ property or instance variable, even a derived one. NSTextField does have a ‘isBordered’ property but not a binding – so you cannot bind ‘isBordered’.

    It does not mean anything to ‘bind’ an arbitrary property of an arbitrary Class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an activity which shows 3 random images from JSON data off the
i have a WebView of an html page which shows only one image http://www.google.fr/intl/en_com/images/srpr/logo1w.png
I have a ImageView which shows a picture that has been taken from the
I have a ImageView and draw some things on that view. Now I want
i have a grid view which contain images when click on one image it
I have a custom baseadapter which does some lazy loading of some images, and
i have an app widget, which contains only one imageview. i redraw that image
I have a simple layout, which shows a text and a image: <?xml version=1.0
I have a button which when clicked shows a checkmark image just inside the
I have an activity which consists of a GridView with multiple (different) images. When

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.