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

  • Home
  • SEARCH
  • 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 873547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:57:18+00:00 2026-05-15T10:57:18+00:00

I am new to cocoa bindings so I tried to make a simple application

  • 0

I am new to cocoa bindings so I tried to make a simple application which will simply calculate avg of employees salary and display it in a text field, using cocoa bindings. I followed these steps:

  1. Made the model class : Person with one property for now –

    @property (readwrite, assign) int salary;

  2. In the application delegate class I initialized a mutable array : personArray with certain objects like this:

    Person *person1 = [[Person alloc] init];
    person1.salary = 5000;
    
    Person *person2 = [[Person alloc] init];
    person2.salary = 15000;
    
    Person *person3 = [[Person alloc] init];
    person3.salary = 7000;
    
    Person *person4 = [[Person alloc] init];
    person4.salary = 9000;
    
    Person *person5 = [[Person alloc] init];
    person5.salary = 11000;
    
    personArray= [[NSMutableArray alloc] initWithObjects:person1, person2, person3, person4, person5,nil];
    
  3. In IB I dropped a NSArrayController object, set its mode as Class – Person, added key salary in attribute pane. Then in bindings pane, binded contents array to ApplicationDelegate class with model key path set to self.personArray.

  4. Dropped a NSTextField on window. Binded its value to ArrayController object. Assigned controller key as – arrangedObjects. Assigned Model key path to @avg.salary

When I executed the application I found no value being displayed in the text field.

Can anyone suggest me where I may be wrong or some other best way to accomplish it

Thanks,

Miraaj

  • 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-15T10:57:18+00:00Added an answer on May 15, 2026 at 10:57 am

    The problem reported above is resolved now, I did following improvements to resolve it:

    1. I declared property for – personArray in ApplicationDelegate class.

    2. In place of assigning Person objects directly to personArray, I first assigned them to a temporary array and then I assigned it to personArray using: -setValue:forKey: method.

    It now works as intended 🙂

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

Sidebar

Related Questions

I'm fairly new to the world of bindings in cocoa, and I'm having some
I'm fairly new to Cocoa and Objective-C. Currently I'm developing a fairly basic application
I'm new in Cocoa. My Application require to use third-party framework to be able
I'm Delphi programmer and very new to Cocoa. at first I tried this :
After creating new cocoa application,I have added localization string files localizeFile.strings(English) and localizeFile.strings(Spanish) In
Why does NSColorPanel accumulate memory usage? Try it: Create a brand new cocoa-based application
I'm quite new to Cocoa Bindings, but I've seen enough that I'd love to
When you create new Cocoa application Xcode generates MainMenu.xib for you with the sets
In Xcode 4 I created a new Cocoa application called Tabletest , on the
Even the standard blank-window Cocoa app that gets built when you make a new

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.