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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:58:42+00:00 2026-05-27T01:58:42+00:00

how could it be translated to unmanaged c++ from objective c 1) property (

  • 0

how could it be translated to unmanaged c++ from objective c

1) property ( nonatomic, assign, getter = isCanceled ) BOOL canceled;

by the way – isCanceled = false; so why not to wright `property ( nonatomic, assign) BOOL canceled;

as in another part of code with other operators:

2) property ( nonatomic, retain ) Im* img;

and is this construction is simply constant in c++?

3) property ( nonatomic, readonly ) Parameter* firstPar; so is this in c++ something like variable const Parameter* firstPar; ?

and how to translate first and second properties correctly???

  • 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-27T01:58:43+00:00Added an answer on May 27, 2026 at 1:58 am

    I don’t have a lot of experience in Objective C, but as far as I understand, the translation would be following:

    // property ( nonatomic, assign, getter = isCanceled ) BOOL canceled
    private:
      bool canceled;             // inner backing field
    public:
      bool isCanceled() const // getter has a special name
      {
          return canceled;
      }
      void setCanceled(bool newCanceled) // standard setter
      {
          canceled = newCanceled;
      }
    

    For the pointer properties with retain, it’s better to use a shared pointer. However, the outer code must adhere to its semantics.

    // property ( nonatomic, retain ) Im* img;
    private:
      // we could use manual retain/release with some kind of shared pointers,
      // but an easier way would be to use automatic refcounting
      std::shared_ptr<Im*> img; // shared_ptr because retain
    public:
      Im* getImg() // getter
      {
          return img.get();
      }
      void setImg(Im* newImg) // setter
      {
          img.reset(newImg);
      }
    

    The third is the simplest. No need of shared pointers, as no retain involved.

    // property ( nonatomic, readonly ) Parameter* firstPar;
    private:
      Parameter* firstPar;
    public:
      Parameter* getFirstPar()
      {
          return firstPar;
      }
      // no setter because readonly
    

    etc.

    C++ doesn’t have the notion of fields, so you have to emulate them a la Java, by manually creating getters and setters.

    Edit:
    thank to the discussion in the comments, I’ve corrected the answer by removing the mutex guard. It would be needed if there were atomic instead.

    With atomic, you would need an additional mutex:

    // property ( atomic, assign, getter = isCanceled ) BOOL canceled
    private:
      bool canceled;             // inner backing field
      std::mutex canceledGuard;  // ensure atomicity
    public:
      bool isCanceled() const // getter
      {
          std::lock_guard<std::mutex> lock(canceledGuard);
          return canceled;
      }
      void setCanceled(bool newCanceled) // setter
      {
          std::lock_guard<std::mutex> lock(canceledGuard);
          canceled = newCanceled;
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to translate some code from objective c to unmanaged c++ I
How could I use the NSFetchedResultsController with translated sort key and sectionKeyPath? Problem: I
I have translated some code from C# to VB.net for the purpose of getting
I've got some code originating from a DSL that needs to be translated for
I could translate Django Admin except a model label because I don't know how
Could someone translate this, into a syntax that uses the built in variables? \\myserver\builds\mybuild\Daily_20090525.1\Release\_PublishedWebsites\myWebsite
Could someone help me translate the following pseudo-code into code understood by Helicon Tech's
Could you tell me how to translate the following SQL code to Linq To
Could someone recommend any good resources for creating Graphics User Interfaces, preferably in C/C++?
Could someone tell me what the units the SetTimeout(int) method in the ICriteria interface

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.