Hello,
I'd like to know if events can be overloaded in a subclass using OBJ-C.
Currently, I am testing out some stream related code, and needed a way to get the offset in the stream, I decided to create a custom stream class which keeps track of every read.
I think I must be overlooking something pretty fundamental here... Could anyone enlighten me?
Thanks a lot!
I'd like to know if events can be overloaded in a subclass using OBJ-C.
Currently, I am testing out some stream related code, and needed a way to get the offset in the stream, I decided to create a custom stream class which keeps track of every read.
Code:
// Header
@interface MyInputStream : NSInputStream{
unsigned int offset;
}
- (int) read:(uint8_t) * buffer maxLength:len;
@end
// Implementation
@implementation MyInputStream
- (int) read:(uint8_t) * buffer maxLength:len
{
int read;
NSLog(@"Here I am, JH);
read=[base read:buffer maxLength:len];
if(read>0)
{
offset+=read;
}
return read;
}
@end
// calling code
MyInputStream* stream=[[MyInputStream alloc]initWithFile:filePath];
[stream read:&buffer maxLength:len]; // No log at all, the overriden message does not get fired...
Thanks a lot!