Câu hỏi phỏng vấn Objective-C
Câu hỏi

What are the differences between implementin...

Câu trả lời

Here are the key differences between implementing an Objective-C property with @dynamic vs @synthesize:

@synthesize

  • Automatically generates the instance variable and accessor methods (getter and setter) for the property
  • The instance variable name is the same as the property name by default, unless you specify a different name using @synthesize property=ivar_name
  • If you don't provide a custom implementation of the getter/setter, the compiler will generate the default implementations for you
  • Example:
objc Copy
@property (nonatomic, copy) NSString *name;
@synthesize name;

@dynamic

  • Tells the compiler that you will provide the implementation of the accessor methods yourself, either in the @implementation block or in a category
  • No instance variable is generated by the compiler
    -...
senior

senior

Gợi ý câu hỏi phỏng vấn

junior

What is a protocol, and how do you define your own and when is it used?

junior

Explain types of protocol in Objective-C

senior

What is the difference between NSMapTable vs NSDictionary ?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào