views:

23

answers:

1

Does Anyone have any idea why this code produces this errors in OS 3.0 and not OS 2.2.1?

NSUInteger aCount = [serverBrowser.servers count];

error: type of accessor does not match the type of property 'servers'

ServerBrowser.h is define below and serverBrowser is synthesized in .m above.

#import <Foundation/Foundation.h>

    @class ServerBrowserDelegate;

    @interface ServerBrowser : NSObject {
      NSMutableArray* servers;
      id<ServerBrowserDelegate> delegate;
    }

    @property(nonatomic,readonly) NSArray* servers;


    @end

Thanks in advance for the help. Much appreciated. Jordan

A: 

It has to do with the fact that you provide the @property for the servers array as an NSArray*, but declare the backing instance variable as an NSMutableArray*. The OS 3.0 compiler may just come with stricter compiler settings than 2.2.1. Try converting to:

@property(nonatomic,readonly) NSMutableArray *servers;
Tim
absolutely right, I can't believe I didn't catch that (smile). I got hung up on the code, since it worked in 2.2.1. Good one @Tim. Cheers!
Jordan