This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Dictionary { | |
static func union(dic: Dictionary, other: Dictionary?) -> Dictionary { | |
var mutableCopy = dic | |
mutableCopy.add(other: other) | |
return mutableCopy | |
} | |
mutating func add(other: Dictionary?) -> Void { | |
guard let other = other else { return } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let filePath = Bundle.main.pathForResource("YOUR_FILE_NAME", ofType: "json", inDirectory: nil) | |
if let filePath = filePath { | |
do { | |
let fileUrl = URL(fileURLWithPath: filePath) | |
let jsonData = try Data(contentsOf: fileUrl, options: .mappedIfSafe) | |
let json = try? JSONSerialization.jsonObject(with: jsonData) | |
} catch { | |
print(error) | |
fatalError("Unable to read contents of the file url") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension URLRequest { | |
public var curlString: String { | |
// Logging URL requests in whole may expose sensitive data, | |
// or open up possibility for getting access to your user data, | |
// so make sure to disable this feature for production builds! | |
#if !DEBUG | |
return "" | |
#else | |
var result = "curl -k " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIView { | |
func roundCorners(_ corners: UIRectCorner, radius: CGFloat) { | |
let path = UIBezierPath(roundedRect: self.bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius)) | |
let mask = CAShapeLayer() | |
mask.path = path.cgPath | |
self.layer.mask = mask | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"People" : [ | |
"😀", | |
"😃", | |
"😄", | |
"😁", | |
"😆", | |
"😅", | |
"😂", | |
"🤣", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
to remove your current version you could just run: | |
sudo gem uninstall cocoapods | |
to update repo | |
pod repo update | |
you can install a specific version of cocoa pods via the following command: | |
sudo gem install cocoapods -v 0.25.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (NSString *)localizedStrinByKey:(NSString *)key forLanguage:(NSString *)languageCode | |
{ | |
NSLog(@"language: %@", languageCode); | |
NSString *path = [[ NSBundle mainBundle ] pathForResource:languageCode ofType:@"lproj"]; | |
NSBundle *bundle = [NSBundle bundleWithPath:path]; | |
return [bundle localizedStringForKey:key value:NSLocalizedString(key, nil) table:nil]; | |
} |