Q: Whether C# interfaces and objective c @prototypes are same? and when the function inside the prototype are optional and when they are compulsory.
A: These are basically the same. Objective-C uses protocols like C# uses interfaces. By default all methods that you list are required (meaning the compiler will complain if it doesn't see the object implement the method, but the program will still compile).
Q: What is meaning of @property (nonatomic, retain)
A:@property
means you are declaring a property. nonatomic
means that the reading/writing of the property will not be thread safe, but it makes it much faster. If you need a thread safe property, you must use atomic
(for which you simply leave out nonatomic
, as atomic
is the default. retain
means that the retainCount automatically increases when you set the property, so you don't have to perform the [someVariable retain]
call yourself. This has major memory management implications, so that's why you will frequently see a call to synthesize with an underscored ivar like so: @synthesize myObject = _myObject;