mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Add try-catch
This commit is contained in:
@@ -56,6 +56,8 @@
|
||||
|
||||
+ (MTQueue * _Nonnull)contextQueue;
|
||||
|
||||
+ (void)performWithObjCTry:(dispatch_block_t _Nonnull)block;
|
||||
|
||||
- (instancetype _Nonnull)initWithSerialization:(id<MTSerialization> _Nonnull)serialization encryptionProvider:(id<EncryptionProvider> _Nonnull)encryptionProvider apiEnvironment:(MTApiEnvironment * _Nonnull)apiEnvironment isTestingEnvironment:(bool)isTestingEnvironment useTempAuthKeys:(bool)useTempAuthKeys;
|
||||
|
||||
- (void)performBatchUpdates:(void (^ _Nonnull)())block;
|
||||
|
||||
@@ -283,6 +283,13 @@ static int32_t fixedTimeDifferenceValue = 0;
|
||||
return queue;
|
||||
}
|
||||
|
||||
+ (void)performWithObjCTry:(dispatch_block_t _Nonnull)block {
|
||||
@try {
|
||||
block();
|
||||
} @finally {
|
||||
}
|
||||
}
|
||||
|
||||
- (void)cleanup
|
||||
{
|
||||
NSDictionary *datacenterAuthActions = _datacenterAuthActions;
|
||||
|
||||
@@ -1093,13 +1093,25 @@ class Keychain: NSObject, MTKeychain {
|
||||
}
|
||||
|
||||
func setObject(_ object: Any!, forKey aKey: String!, group: String!) {
|
||||
let data = NSKeyedArchiver.archivedData(withRootObject: object)
|
||||
self.set(group + ":" + aKey, data)
|
||||
guard let object = object else {
|
||||
return
|
||||
}
|
||||
MTContext.perform(objCTry: {
|
||||
let data = NSKeyedArchiver.archivedData(withRootObject: object)
|
||||
self.set(group + ":" + aKey, data)
|
||||
})
|
||||
}
|
||||
|
||||
func object(forKey aKey: String!, group: String!) -> Any! {
|
||||
guard let aKey = aKey, let group = group else {
|
||||
return nil
|
||||
}
|
||||
if let data = self.get(group + ":" + aKey) {
|
||||
return NSKeyedUnarchiver.unarchiveObject(with: data as Data)
|
||||
var result: Any?
|
||||
MTContext.perform(objCTry: {
|
||||
result = NSKeyedUnarchiver.unarchiveObject(with: data as Data)
|
||||
})
|
||||
return result
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user