vinoth.kumar
vinoth.kumar

Reputation: 92

readwrite and readonly mutually exclusive

How can I go about achieving this

Upvotes: 0

Views: 78

Answers (2)

Sakthivel Sugumar
Sakthivel Sugumar

Reputation: 21

Try like the following example

In your .h:

@property(nonatomic, retain, readonly) NSDate* theDate;

In your .m:

@interface TheClassName()
@property(nonatomic, retain, readwrite) NSDate* theDate;
@end

Upvotes: 1

rob mayoff
rob mayoff

Reputation: 385600

In Objective-C:

MyObject.h

@interface MyObject : NSObject

@property (nonatomic, readonly, strong) NSString *myProperty;

@end

MyObject.m

// Class extension
@interface MyObject ()

// Redeclare property read-write
@property (nonatomic, readwrite, strong) NSString *myProperty;

@end

@implementation MyObject

...

In Swift:

class MyObject {

    private(set) var myProperty: String

    ...

Upvotes: 1

Related Questions