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 8048789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:35:25+00:00 2026-06-05T06:35:25+00:00

In language Cocoa uses to define view constraints , examples are always named button1,

  • 0

In language Cocoa uses to define view constraints, examples are always named “button1”, “button2”, etc. But what do this names actually mean? Are they names of the nub files, the class names of controllers or views? If I instantiate several views of the same nib file and class, what names do they get, and how can I set them?

  • 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-06-05T06:35:27+00:00Added an answer on June 5, 2026 at 6:35 am

    They are placeholders that will be associated with actual buttons in your nib file.

    Update

    If you’re adding constraints in code using addConstraints:options:metrics:views: method on view you’re trying to constraint (whether that instance of UIView was created in code or loaded from nib), the last parameter (views:) accepts dictionary who’s keys are the ones you provide in UIConstraint‘s ascii art (button1, button2, etc.) and values are actual views that you create in code or get the instances from somewhere else (IBOutlet maybe).

    You can create the dictionary quickly by using NSDictionaryOfVariableBindings macro which will accept variable number of your instances of views and associate them with same placeholder names like names of those instances. E.g.

    // This is a ASCII constraint:
    NSString *constraintAscii = @"|-[button1]-12-[button2]-|";
    
    // Bound views for constraints:
    UIButton *button2 = ... // code to create button2 variable
    // let's say that button1 is actually an IBOutlet for instance variable
    // now we create the dictionary of views for our new constraint
    NSDictionary *views = NSDictionaryOfVariableBindings(button1, button2);
    
    // now we create the constraint using these variables
    NSArray *constraints = [NSLayoutConstraint constraintsWithVisualFormat: constraintAscii
                                                                   options: 0
                                                                   metrics: nil
                                                                     views: views];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there API available in any language that can run on a Mac (Perl/Python/Cocoa/etc)
Language: asp This is sample of my code: str = www.example.com/gotobuy.aspx?id=1234 key_word = .obuy.
I'm rather new to programming in Cocoa, but I've been working on learning the
I am trying to make a simple markup language, and I need my Cocoa
I'm working on an Objective-C/Cocoa roguelike, because I've always found that working on a
I'm a noob to Cocoa programming, so please excuse the possible stupidity of this
This isn't a style question. Its more about the proper use of the language
Somebody told me about a class for language recognition in Cocoa. Does anybody know
I've used NSNotifications before but this is the first time I've tried to use
My Cocoa application uses NSTextView. It is sort of an editor application. Now in

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.