Skip to content

Instantly share code, notes, and snippets.

View fmessina's full-sized avatar

Ferdinando fmessina

View GitHub Profile
@fmessina
fmessina / TableViewControllerRightLabelCell.swift
Last active March 27, 2018 07:08
Add a custom label on the right on UITableViewCell
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cellIdentifier = "CellIdentifier"
let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier) ?? UITableViewCell(style: .value1, reuseIdentifier: cellIdentifier)
let label = UILabel()
label.textAlignment = .right
label.backgroundColor = UIColor.clear
label.textColor = UIColor.gray
label.translatesAutoresizingMaskIntoConstraints = false
cell.detailTextLabel?.text = "TEST"
@fmessina
fmessina / KeychainPrinter.m
Last active April 5, 2018 14:46
Print all the existing keys in the iOS keychain
+ (void)showKeychainKeys {
NSMutableDictionary *query = [NSMutableDictionary dictionaryWithObjectsAndKeys:
(__bridge id)kCFBooleanTrue, (__bridge id)kSecReturnAttributes,
(__bridge id)kSecMatchLimitAll, (__bridge id)kSecMatchLimit,
nil];
NSArray *secItemClasses = [NSArray arrayWithObjects:
(__bridge id)kSecClassGenericPassword,
@fmessina
fmessina / ChilViewController.m
Last active February 13, 2018 09:42
Adding and removing a view controller on top of another - on iOS - without using modal presentation
// GOAL
// viewControllerA
// |_ viewControllerB
UIViewController *viewControllerA = ...;
UIViewController *viewControllerB = ...;
// Adding
[viewControllerA addChildViewController:viewControllerB];
[viewControllerA.view addSubview:viewControllerB.view];