Red > Green > Refactor > Red

cycle is based on desire

@property(readonly) 's initialization(initialize)

Benedict's Soapbox » Defining an Objective-C @property as Publicly readonly and Privately readwrite

  • readonly in outside interface
  • readwrite in inside interface and implementation (and synthesize)


#import <UIKit/UIKit.h>

@interface XYZViewController : UIViewController
@property(readonly, atomic, retain) NSString *read_str;


#import "XYZViewController.h"

@interface XYZViewController ()
@property (readwrite, atomic, retain) NSString *read_str;

@implementation XYZViewController
@synthesize read_str;

- (void)viewDidLoad {
  [super viewDidLoad];
  [self init];

- (id) init {
  self = [super init];
  if(self) {
    self.read_str = @"read str";
  return self;