Skip to content

Instantly share code, notes, and snippets.

View i0sa's full-sized avatar

Osama Gamal i0sa

View GitHub Profile
struct BaseResponse<T: Codable>: Codable {
var status: Bool?
var message: String?
var data: T
required init(from decoder:Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
//MARK: Decode all types of messages (message_ar, message, error)
//
// AnimationsFactory.swift
// instapay
//
// Created by Osama on 6/6/20.
// Copyright © 2020 Osama Gamal. All rights reserved.
//
import Foundation
import UIKit
@i0sa
i0sa / Codable+IntString.swift
Last active June 15, 2020 10:20
Codable+IntString.swift
struct MyStruct: Codable {
let price: Int?
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
if let intPrice = try? container.decode(Int?.self, forKey: .price){
self.price = intPrice
} else if let stringPrice = try? container.decode(String.self, forKey: .price){
self.price = Int(stringPrice) ?? nil
} else {
@i0sa
i0sa / NormalCode.swift
Created June 26, 2020 22:31
Normal code
@implementation HomeViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self loadNetworkData];
}
@end
%hook HomeViewController
-(void)viewDidLoad{
%orig;
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"My Alert"
message:@"This is an injected alert."
preferredStyle:UIAlertControllerStyleAlert];
[self presentViewController:alert animated:YES completion:nil];
}
%end
@interface UserManager : NSObject
-(BOOL)isLoggedIn;
@end
%hook UserManager
-(BOOL)isLoggedIn{
return true;
}
%end
@i0sa
i0sa / AppStoryboard.swift
Created October 8, 2020 21:18 — forked from Gurdeep0602/AppStoryboard.swift
AppStoryboard enumeration
//
// AppStoryboards.swift
// AppStoryboards
//
// Created by Gurdeep on 15/12/16.
// Copyright © 2016 Gurdeep. All rights reserved.
//
import Foundation
import UIKit