Anand
Anand

Reputation: 10400

Warnings on creating private setters in Objective C

I have two properties declared for my class in its interface file Account.h

@interface Account : NSObject {
    NSString* username;
    NSString* password;
}

@property (readonly) NSString* username;
@property (readonly) NSString* password;

@end 

And I have created private setters in its implementation file Account.m

@interface Account()

@property (copy, readwrite) NSString* username;
@property (copy, readwrite) NSString* password;

@end

But, I get warnings from XCode (v3.x) on the above two lines in the implementation file. And this is the warning.

warning: property 'username' attribute in 'Account' class continuation does not match class 'Account' property

Why is this warning given by XCode. These warnings are all over my project. Am I missing something?

Upvotes: 0

Views: 102

Answers (1)

Ole Begemann
Ole Begemann

Reputation: 135588

You have to include the copy specifier in the .h file as well:

@property (copy, readonly) NSString* username;
@property (copy, readonly) NSString* password;

Upvotes: 3

Related Questions