views:

42

answers:

1

Given the following example

// MyClass.h
@interface MyClass {
  NSMutableArray *queue;
}

@property (readonly, retain) NSArray *queue;

@end

and

// MyClass.m
@interface MyClass ()

@property (readwrite, retain) NSMutableArray *queue;

@end



@implementation MyClass

@synthesize queue;

@end

I get a Property 'queue' type in 'MyClass' class continuation does not match class 'MyClass' property warning from the compiler. What is the best way to add "private" covariant setters to a class without writing them by hand?

A: 

You did it correctly. The issue here is NSArray isn't an NSMutableArray. If you make the private property a NSArray as well, and then write your own setter that accepts a NSMutableArray it should work as expected.

Joshua Weinberg