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???
I don’t have a lot of experience in Objective C, but as far as I understand, the translation would be following:
For the pointer properties with retain, it’s better to use a shared pointer. However, the outer code must adhere to its semantics.
The third is the simplest. No need of shared pointers, as no
retaininvolved.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
atomicinstead.With
atomic, you would need an additional mutex: