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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:33:46+00:00 2026-05-20T09:33:46+00:00

Well, I’ve been programming for VB.NET for a while, and now I am interested

  • 0

Well, I’ve been programming for VB.NET for a while, and now I am interested in programming Mac applications instead.

I know Objective-C alright. But, of course, I need to understand Cocoa/Xcode’s development environment. I understand the Interface Builder is the equivalent to the Form Designer in VB.NET and other common concepts both environments seem to share.

Now, I will begin with something basic:

In VB.NET, I would use the Paint function to get a Graphics object and draw a red rectangle somewhere in my window. What is the equivalent in Cocoa?

Thank you. I know my question is quite specific (how to make a red rectangle in the window), but that is one of the few things I need to understand better since I can work from that point on.

  • 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-20T09:33:47+00:00Added an answer on May 20, 2026 at 9:33 am

    The most straight-forward way to do something like that would be to subclass the standard view class and implement the -[drawRect:] method. These are handled slightly different between UIKit (iOS) and AppKit (Mac OS X). For example, to paint a red box the size of a view’s visible bounds in iOS, you’d subclass UIView and then implement a drawRect: like so:

    - (void)drawRect:(CGRect)rect
    {
      [[UIColor redColor] setFill]; // set the fill color
      UIRectFill([self bounds]);    // fill a box (this view's visible bounds)
    }
    

    To do the same thing in Mac OS X, you’d subclass NSView and then implement a drawRect: like so:

    - (void)drawRect:(NSRect)rect
    {
      [[NSColor redColor] setFill]; // set the fill color
      NSRectFill([self bounds]);    // fill a box (this view's visible bounds)
    }
    

    For more information, you can take a look at the Cocoa Drawing Guide for working with Mac OS X and AppKit or the Drawing and Printing Guide for iOS for working with iOS and UIKit.

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

Sidebar

Related Questions

Well I have been through many sites teaching on how to solve it, but
Well, after a long time writing .net programs in C# I started to feel
Well... simple question, right? But with no so simple answers. In firefox i use
Well, it seems simple enough, but I can't find a way to add a
well i was PointToScreen() but when the control is inside a group box this
Well this question and this question are similar but no answers that work. In
Well the subject is the question basically. Are there any version control systems out
Well, i've got a nice WPF book its called Sams Windows Presentation Foundation Unleashed.
Well behaved windows programs need to allow users to save their work when they
Well, this is my first post here and really enjoying the site. I have

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.