DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Trending

  • Spring WebFlux Retries
  • Build a Serverless App Fast With Zipper: Write TypeScript, Offload Everything Else
  • Next.js vs. Gatsby: A Comprehensive Comparison
  • Mastering Persistence: Why the Persistence Layer Is Crucial for Modern Java Applications

Cocoa C++ Wrappers

Alex Curylo user avatar by
Alex Curylo
·
May. 13, 11 · News
Like (0)
Save
Tweet
Share
4.58K Views

Join the DZone community and get the full member experience.

Join For Free

So let’s say that you’re looking at developing an iPhone app that needs to share source with Another Platform, so C++ is the logical common ground; but you’d like to keep your iPhone side written the right way, of course. Here’s a helpful post about wrapping std::vector in an NSArray:

Mixing STL, NSArray and Bindings

I am currently writing a crossplatform library that needed to be quick, small and efficient. The library is a parser for a particular file format that I need to work with. The library needs to work on Mac, Windows, and with Java through JNI.

I thought about using Objective-C for the engine and then using GNU-Step or CocoTron but that has a huge overhead and writing the JNI would be a night mare. I didn’t want to write it in straight C, i wanted to use STL’s strings and collection classes and boost’s smart pointers. So C++ it was.

When writing the Objective-C wrapper and test app I wanted to use Cocoa’s bindings mechanism to quickly display the results. The solution was to wrap the classes, very thinly, using an NSArray wrapper around the vector.

In this article we will walk through writing a thin wrapper around a C++ object that parses lines of text out of stores those lines in a vector of strings. The sample project can be downloaded from here…


Another interesting bit here:

Hoard: A Nice Abstraction on Cocoa Collections

… Hoard gives you a super simple way to instantiate collections of any sort, containing data of any type, and then “view” that data as one of several available collection types (including both Cocoa and STL collections). You can also instantiate a hoard from any of the included Cocoa or STL collections…


Any libraries, patterns, or snippets to add here that you’ve found useful in constructing C++/Objective-C core functionality engine bits, Dear Readers?

Cocoa (API)

Published at DZone with permission of Alex Curylo, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.


Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: