mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
72 lines
945 B
Objective-C
72 lines
945 B
Objective-C
#import "TGDataResource.h"
|
|
|
|
@interface TGDataResource ()
|
|
{
|
|
NSData *_data;
|
|
NSInputStream *_stream;
|
|
UIImage *_image;
|
|
bool _imageDecoded;
|
|
}
|
|
|
|
@end
|
|
|
|
@implementation TGDataResource
|
|
|
|
- (instancetype)initWithData:(NSData *)data
|
|
{
|
|
self = [super init];
|
|
if (self != nil)
|
|
{
|
|
_data = data;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (instancetype)initWithInputStream:(NSInputStream *)stream
|
|
{
|
|
self = [super init];
|
|
if (self != nil)
|
|
{
|
|
_stream = stream;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (instancetype)initWithImage:(UIImage *)image decoded:(bool)decoded
|
|
{
|
|
self = [super init];
|
|
if (self != nil)
|
|
{
|
|
_image = image;
|
|
_imageDecoded = decoded;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)dealloc
|
|
{
|
|
[_stream close];
|
|
}
|
|
|
|
- (NSData *)data
|
|
{
|
|
return _data;
|
|
}
|
|
|
|
- (NSInputStream *)stream
|
|
{
|
|
return _stream;
|
|
}
|
|
|
|
- (UIImage *)image
|
|
{
|
|
return _image;
|
|
}
|
|
|
|
- (bool)isImageDecoded
|
|
{
|
|
return _imageDecoded;
|
|
}
|
|
|
|
@end
|