Hi everyone I have a really strange problem. I create a new subclass of NSObject, but I just cannot use “self.someproperty” in the implementation. Normally when I type the word “self”, Xcode will guess what I’m typing and give me the property name after dot. But in this case, it doesn’t and give me an red error. I have check my code for a night and give up now. So, wish some one give me a advise please let me know this might be a small problem somewhere?
Here’s my code:
#import <Foundation/Foundation.h>
@interface FlickrPhotoCache : NSObject
+(BOOL)isInCache:(NSDictionary *)photo;
@end
#import "FlickrPhotoCache.h"
@interface FlickrPhotoCache()
@property (nonatomic, strong) NSMutableArray *photos;
@end
@implementation FlickrPhotoCache
@synthesize photos = _photos;
+(BOOL)isInCache:(NSDictionary *)photo
{
self.photos // here I get error
}
@end
Thanks in advance! WHT
You’re using + when declaring the method which is for static (class) methods not instance methods
selfonly exists in the instance methods.Use
When declaring to use the instance variable
selffor properties.And then
Works just fine.