[英]readwrite and readonly mutually exclusive
我該如何實現這一目標
必須對類的內部實現進行屬性讀寫
屬性必須是只讀的,以便與類的實例進行外部交互
@interface MyObject : NSObject
@property (nonatomic, readonly, strong) NSString *myProperty;
@end
// Class extension
@interface MyObject ()
// Redeclare property read-write
@property (nonatomic, readwrite, strong) NSString *myProperty;
@end
@implementation MyObject
...
class MyObject {
private(set) var myProperty: String
...
嘗試像下面的例子
在您的.h中:
@property(nonatomic, retain, readonly) NSDate* theDate;
在您的.m中:
@interface TheClassName()
@property(nonatomic, retain, readwrite) NSDate* theDate;
@end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.