Skip to content

Instantly share code, notes, and snippets.

@jinjereu
jinjereu / IfAvailables.swift
Created October 1, 2019 22:04
Using #available vs @available
//Use #available to do version-specific code in small blocks
func foo() {
if #available(iOS 9, *) {
//use UIStackView for example
} else {
//do something else
}
}
//Use @available attribute when addressing whole methods or classes to be only available
@jinjereu
jinjereu / NSUserDefaults+AppUserDefaults.m
Created August 5, 2019 23:11
Sample NSUserDefaults category
//
// NSUserDefaults.m
//
//
// Created by Ingrid Silapan on 6/08/19.
// Copyright © 2019 irs. All rights reserved.
//
#import "NSUserDefaults+AppUserDefaults.h"
@jinjereu
jinjereu / MySingletonClass.m
Created July 12, 2019 04:42
Implement Objective-C Singleton
@implementation MySingletonClass
+ (MySingletonClass *)sharedInstance
{
static MySingletonClass *sharedInstance;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [self new];
//Perform additional initialization
});
@jinjereu
jinjereu / AlertWithTextField.m
Last active June 11, 2019 10:52
Show Alert with textfield in Objective-C
@implementation AlertWithTextField
- (void)showAlertInViewController:(UIViewController *)vc{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"New Name"
__weak typeof(ViewController) *weakSelf = self;
[alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
textField.placeholder = @"Enter name";
}];
@jinjereu
jinjereu / GetAppDelegateViewController.m
Last active June 11, 2019 10:47
Getting a reference to UIApplication delegate in Objective-C
#import "GetAppDelegateViewController.h"
@implementation GetAppDelegateViewController
- (void)viewDidLoad {
[super viewDidLoad];
MyAppDelegate *delegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
}
@jinjereu
jinjereu / .gitignore
Last active July 20, 2019 10:30
Default Gitignore configurations for iOS Project
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
## Build generated
build/
DerivedData/
## Various settings
*.pbxuser
@jinjereu
jinjereu / .swiftlint.yml
Last active November 14, 2018 22:42
Default SwiftLint configurations for iOS Project
# add additional rules to disable them
disabled_rules:
- trailing_whitespace
# limit line length to 300
line_length: 300
# some rules are only opt-in
opt_in_rules:
- empty_count
@jinjereu
jinjereu / ios_top_libs.md
Created November 14, 2018 01:33
List of Top iOS Libraries and Frameworks

List of Top iOS Libraries and Frameworks

Security and Encryption

  1. RNCryptor - Cross-language AES Encryptor/Decryptor data format.
  2. SSKeychain - Simple Objective-C wrapper for the keychain that works on Mac and iOS

Networking

  1. Alamofire - Alamofire is an HTTP networking library written in Swift
  2. AlamofireNetoworkActivityLogger - Network activity logger for Alamofire.
  3. AlamofireImage - AlamofireImage is an image component library for Alamofire.
@jinjereu
jinjereu / README.md
Created November 13, 2018 03:48 — forked from hofmannsven/README.md
My simply Git Cheatsheet