34794

Call an Objective-C function from C++ library code

Question:

I'd like to call a Obj-C function from my C++ code, in order to invoke a ShareKit call from a game engine.

How do I perform the Obj-C function call?

I'm using Cocos2d-x.

Answer1:

Use Objective-C++. To do that, you make a C++ file with the extension “.mm”. Within that file, both Objective-C and C++ syntax are valid, so you can #import your Objective-C headers and send messages using the [] syntax.

Recommend

  • Posting message along with an image on Facebook [duplicate]
  • Changing the title of a MFMailComposeViewController
  • Social networking integration with OAuth in iPhone
  • Is it expensive to create the Thread object or to actually start the thread?
  • Python 3 Sorting a List of Tuples?
  • Different builds of turn-based Game Center game can’t see each other’s matches
  • opengl window freezing during move/resize
  • How to load gif image while ajax content is loading and javascript [duplicate]
  • Installing PHP 7 on digitalocean
  • Using a canvas object in a thread to do simple animations - Java
  • WPF ICommand CanExecute(): RaiseCanExecuteChanged() or automatic handling via DispatchTimer?
  • Unable to get column index with table.getColumn method using custom table Model
  • MonoTouch: How to download pdf incrementally as indicated in the Apple slides “Building Newsstand Ap
  • Transactional Create with Validation in ServiceStack Redis Client
  • Hardware Accelerated Image Scaling in windows using C++
  • JQuery Internet Explorer and ajaxstop
  • Use of this Javascript
  • Error when parsing timestamp with pandas read_csv
  • Breeze - Deleted Items nav properties bug
  • javaw.exe and eclipse startup problems
  • Is there a mandatory requirement to switch app.yaml?
  • ExecuteAsync RestSharp to allow backgroundWorker CancellationPending c#
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • Benchmarking RAM performance - UWP and C#
  • Acquiring multiple attributes from .xml file in c#
  • Suggestions to manage Login/Logout transitions
  • What are the advantages and disadvantages of reading an entire file into a single String as opposed
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Change div Background jquery
  • need help with bizarre java.net.HttpURLConnection behavior
  • How does Linux kernel interrupt the application?
  • How can I remove ASP.NET Designer.cs files?
  • Busy indicator not showing up in wpf window [duplicate]
  • Reading document lines to the user (python)
  • Binding checkboxes to object values in AngularJs
  • Why do underscore prefixed variables exist?
  • java string with new operator and a literal
  • Net Present Value in Excel for Grouped Recurring CF
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?