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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:30:50+00:00 2026-05-22T23:30:50+00:00

Please, could you give me examples of how to create the NSBox instance runtime

  • 0

Please, could you give me examples of how to create the NSBox instance runtime to place it inside the NSView?

  • 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-22T23:30:51+00:00Added an answer on May 22, 2026 at 11:30 pm
    NSView *superview = …; // Reference to the view that will contain the box
                           // for instance, [window contentView]
    
    NSUInteger resizeAllMask = (NSViewWidthSizable
        | NSViewHeightSizable
        | NSViewMinXMargin
        | NSViewMaxXMargin
        | NSViewMinYMargin
        | NSViewMaxYMargin);
    
    // This is the box. We use an autoresizing mask so that it occupies
    // the entire superview 
    NSBox *box = [[NSBox alloc] initWithFrame:[superview bounds]];
    [box setAutoresizingMask:resizeAllMask];
    [box setBoxType:NSBoxPrimary];
    [box setBorderType:NSBezelBorder];
    [box setTitle:@"This is a box"];
    
    // This is the box' content view. It represents the box contents.
    // By default, a box autoresizes its content view so that it occupies
    // the entire box
    NSView *boxContentView = [[NSView alloc] initWithFrame:NSZeroRect];
    [box setContentView:boxContentView];
    
    // For example, we add a text field to the box' content view
    NSRect textRect = {{0,0}, {100,20}};
    NSTextField *textField = [[NSTextField alloc] initWithFrame:textRect];
    [textField setStringValue:@"Hey there"];
    [boxContentView addSubview:textField];
    
    [superview addSubview:box];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could someone please give me a link on how to create a query in
Could anyone give me examples of how to use parameterized queries with MySQL/PHP please?
How can I create global variables in CUDA?? Could you please give me an
Could anyone please give a sample or any link that describes how to spawn
Could you, please, give a code snippet showing how to use Lua embedded in
Could someone please demystify interfaces for me or point me to some good examples?
What are the advantages of using boost.any library ? Could you please give me
Could someone please give me simple websocket code. I am creating websocket example but
Please could someone give me an example in batch of something like: IF test.txt
Please could someone post an example of how to check if an element exists

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.