BNRImageStore.h has two errors


#1

Currently using Xcode 6, iOS8 on my iPhone 5, everything was going well till I created the two files: BNRImageStore.h and BNRImageStore.m
The compiler is flagging these two lines with the ‘Expected a Type’ error, not sure how to fix it. Any help will be greatly appreciated, thanks.

- (void)setImage:(UIImage *)image forKey:(NSString *)key;
- (UIImage *)imageForKey:(NSString *)key;

#2

Those lines are fine. Can you include the rest of the header file?


#3

I had the same problem and solved it by adding a line to import UIKit.

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@interface BNRImageStore : NSObject

- (void)setImage:(UIImage *)image forKey:(NSString *)key;
- (UIImage *)imageForKey:(NSString *)key;
- (void)deleteImageForKey:(NSString *)key;

works but:


#import <Foundation/Foundation.h>

@interface BNRImageStore : NSObject

- (void)setImage:(UIImage *)image forKey:(NSString *)key;
- (UIImage *)imageForKey:(NSString *)key;
- (void)deleteImageForKey:(NSString *)key;

didn’t. I’m not sure if importing UIKit/UIKit.h is the best way to get rid of this error or if there is a better way, but it works and let me get on with it.


#4

I think it’s better to add this line:

@class UIImage;