Say you have a readonly property class testing).

@interface SPTAlbum
@property (nonatomic, readonly) NSArray *artists;

you want to make it’s properties readwrite (say for unit testing).

Here’s how you do it.

Create the new MockClass extending the readonly class.
Add a readwrite property that you want to overwrite.
Then synthesize it (because it is readonly in the base, it’s doesn’t know how to set so we help it by offering synthesizing it).


#import <Spotify/Spotify.h>

@interface MockSPTAlbum : SPTAlbum
@property (nonatomic, readwrite) NSArray *artists;


#import "MockSPTAlbum.h"

@implementation MockSPTAlbum
@synthesize artists;

Now you should be able to instantiate and set just like any other class. Happy testing!