Error with custom Class definition in protocol
Posted
by Greg
on Stack Overflow
See other posts from Stack Overflow
or by Greg
Published on 2010-05-27T15:23:55Z
Indexed on
2010/05/27
16:01 UTC
Read the original article
Hit count: 188
I'm trying to set up a custom delegate protocol and am getting a strange error that I don't understand. I wonder if someone could point out what I'm doing wrong here (I'm still new to Ob-C and protocol use)...
The situation is that I've built my own URLLoader class to manage loading and parsing data from the internet. I'm now trying to set up a protocol for delegates to implement that will respond to the URLLoader's events. So, below is my protocol...
#import <UIKit/UIKit.h>
#import "URLLoader.h"
/**
* Protocol for delegates that will respond to a load.
*/
@protocol URLLoadResponder <NSObject>
- (void)loadDidComplete:(URLLoader *)loader;
- (void)loadDidFail:(URLLoader *)loader withError:(NSString *)error;
@end
However, I'm getting the following error for both method signatures:
Expected ')' before 'URLLoader'
I feel like I must be overlooking something small and silly. Any help folks could offer would be greatly appreciated!
Whoops ... it was pointed out that I should include URLLoader.h. Here it is:
#import <Foundation/Foundation.h>
#import "URLLoadResponder.h"
/**
* URLLoader inferface.
*/
@interface URLLoader : NSObject {
NSString *name;
NSString *loadedData;
NSMutableData *responseData;
NSObject *delegate;
BOOL _isLoaded;
}
@property (nonatomic, retain) NSString *name;
@property (nonatomic, retain) NSString *loadedData;
@property (nonatomic, retain) NSObject *delegate;
- (void)loadFromURL:(NSString *)url;
- (void)addCompleteListener:(id)observer selector:(SEL)sel;
- (void)removeCompleteListener:(id)observer;
- (void)parseLoadedData:(NSString *)data;
- (void)complete;
- (void)close;
- (BOOL)isLoaded;
+ (NSURL *)makeUrlWithString:(NSString *)url;
+ (URLLoader *)initWithName:(NSString *)name;
@end
© Stack Overflow or respective owner