Search code examples
iosobjective-ciphone-sdk-3.0iphone-sdk-2

Works in OS 2.2.1 but not in OS 3.0: Error: type of accessor?


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


Solution

  • 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;