I am new to iOS programming. Can someone tell me the exact meaning of the next line of code @property(**nonatomic, retain**) UIView *singleTapView;
@property(**nonatomic, retain**) UIView *singleTapView;
I used @property many times, actually knowing the exact meaning of the function (nonatomic, retain or assign or copy). Can anyone help me with this. Thankyou
(nonatomic, retain or assign or copy)
Properties are used in iOS to replace the getter and setter methods that we usually write.
Your line of code:
@property ( non- atomic , save ) UIView * singleTapView;
means you are writing getter and setter methods for your UIView.
UIView, .
, :
@property (, ) UIView * singleTapView;
UIView, . , UIView.
"copy" , .
, .
@property - . .
@property
nonatomic , @synthesize , . , atomic, .. .
nonatomic
@synthesize
atomic
( atomic), @synthesized , / . Apple docs, , , /.
, . .
. , , ,
alloc β init β retain β release
alloc
init
retain
release
. , , , .
, Objective C .
@property, getter setter ....
, , @property
@property(nonatomic,retain) setter, , ...
@property(nonatomic,retain)
, self.variableName, setter, @property
self.variableName
For the non-atomic / atomic part, you should read the Atomic Operation . This does not apply to iOS, but will give you a better understanding.
For the part, saving this code will help you. This is similar to what @synthesizewill generate for you
//getter - (Book *)book { return [[book retain] autorelease]; } //setter - (void)setBook:(Book *)aBook { if (book == aBook) { return; } Book *oldBook = book; book = [aBook retain]; [oldBook release]; }
Source: https://habr.com/ru/post/1795464/More articles:Environment variables for dll are different than exe - c ++Defining a Silverlight combobox popup (dropup) - silverlightProblem with ruby ββnested timeouts over system calls - multithreadingReading JS variable from BHO in IE9 - windowsHow to comment #if, #else, #endif preprocessor design? - c ++Why don't we have stateful protocols running on the Internet? - httpHigh Volume Erlang - loggingRun the specified command on error without try / catch in Matlab - matlabC # parser calculation - stringLoading screens in games (providing animation does not stutter during the transition) - iphoneAll Articles