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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:17:26+00:00 2026-06-08T14:17:26+00:00

I am writing a Cocoa application that uses a C++ library that I am

  • 0

I am writing a Cocoa application that uses a C++ library that I am also writing. I want the C++ library to be able to call a draw method in the Cocoa application.

Specifics – to put it into context, I am running OpenNi skeletal tracking and recording the skeletal data. At each new frame, I want to tell the Objective-C code that it can/should draw the data to screen.

The OpenNI tracking code is called by (and has a handle to) a control object SkeletalModuleControl.
The only object the Objective-C code interacts with is this control class.
My thoughts are that it would be best to create callDraw and registerDraw methods in the control class.
The Objective-C code would register its draw method (or multiple draw methods?) and the callDraw would call the registered draw methods (if any).

  • 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-08T14:17:27+00:00Added an answer on June 8, 2026 at 2:17 pm

    In general, drawing into a Cocoa view should only be done when Cocoa calls the view’s -drawRect: method. So, the question you really need to consider is how to get Cocoa to invalidate your view(s) when you have updated data you want to display…

    Writing a plain-old C function that you can call from your C++ code is probably the simplest approach. Having the C++ library let you register a callback function to invalidate the relevant views is straightforward too. Just keep in mind that either way, the function should only be responsible for invalidating views (e.g. calling -setNeedsDisplay: or -setNeedsDisplayInRect:). The actual drawing needs to happen later, when Cocoa gets around to calling the -drawRect: method(s).

    If you want to put code in the C++ library to do the drawing, just wrap it as a plain-old C function that can be called from -drawRect:.

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

Sidebar

Related Questions

The Problem I'm writing a Cocoa application and I want to raise exceptions that
I'm writing Cocoa code that uses some classes defined in a C++ library. I
So, I'm writing a Cocoa application that needs to be able to display web
In a cocoa application that I'm writing, I want to create several different kinds
I'm writing a Cocoa application that installs itself as an menulet in the menu
I am writing a Cocoa application that makes use of the ParseKit framework (
I am writing a Mac Cocoa application that will manipulate database files, which can
I'm writing a Cocoa application, which uses NSURLs -- I need to remove the
I'm writing a Cocoa application that displays the contents of an archive file in
I'm writing a Cocoa application that displays the contents of an archive file 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.