mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00

git-subtree-dir: submodules/MtProtoKit git-subtree-mainline: 3b155750f5a4894ff3dedf1860a37e94e0ea9571 git-subtree-split: 14ab734b977fd4f1686a2a13415f6a4c9b9fdd6d
72 lines
1.5 KiB
Objective-C
72 lines
1.5 KiB
Objective-C
|
|
|
|
#import "MTDatacenterAddressSet.h"
|
|
|
|
#import "MTDatacenterAddress.h"
|
|
|
|
@implementation MTDatacenterAddressSet
|
|
|
|
- (instancetype)initWithAddressList:(NSArray *)addressList
|
|
{
|
|
self = [super init];
|
|
if (self != nil)
|
|
{
|
|
_addressList = addressList;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (instancetype)initWithCoder:(NSCoder *)aDecoder
|
|
{
|
|
self = [super init];
|
|
if (self != nil)
|
|
{
|
|
_addressList = [aDecoder decodeObjectForKey:@"addressList"];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)encodeWithCoder:(NSCoder *)aCoder
|
|
{
|
|
[aCoder encodeObject:_addressList forKey:@"addressList"];
|
|
}
|
|
|
|
- (BOOL)isEqual:(MTDatacenterAddressSet *)another
|
|
{
|
|
if (![another isKindOfClass:[MTDatacenterAddressSet class]])
|
|
return false;
|
|
|
|
if (_addressList.count != another.addressList.count)
|
|
return false;
|
|
|
|
for (NSUInteger i = 0; i < _addressList.count; i++)
|
|
{
|
|
if (![_addressList[i] isEqual:another.addressList[i]])
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
- (NSString *)description
|
|
{
|
|
NSMutableString *string = [[NSMutableString alloc] init];
|
|
[string appendString:@"["];
|
|
for (MTDatacenterAddress *address in _addressList)
|
|
{
|
|
if (string.length != 1)
|
|
[string appendString:@", "];
|
|
[string appendString:[address description]];
|
|
}
|
|
[string appendString:@"]"];
|
|
|
|
return string;
|
|
}
|
|
|
|
- (MTDatacenterAddress *)firstAddress
|
|
{
|
|
return _addressList.count == 0 ? nil : _addressList[0];
|
|
}
|
|
|
|
@end
|