View KeychainItemWrapper.h
/* | |
File: KeychainItemWrapper.h | |
Abstract: | |
Objective-C wrapper for accessing a single keychain item. | |
Version: 1.2 - ARCified | |
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple | |
Inc. ("Apple") in consideration of your agreement to the following | |
terms, and your use, installation, modification or redistribution of |
View Asymmetric.swift
// | |
// Asymmetric.swift | |
// | |
// Created by David Hoerl on 12/23/18. | |
// Copyright © 2018 David Hoerl. All rights reserved. | |
// | |
/* | |
This is the portion you need in the distributed app, which uses the public key that can appear in plain text | |
*/ |
View AppDelegate(category).m
static NSString *kcIdentifier = @"MyApp"; | |
@implementation LTAppDelegate (KeyChain) | |
- (void)keychainInit | |
{ | |
self.keychainDict = [NSMutableDictionary dictionaryWithCapacity:7]; | |
KeychainItemWrapper *item = [[KeychainItemWrapper alloc] initWithIdentifier:kcIdentifier accessGroup:nil]; | |
[self.keychainDict setObject:@"" forKey:kcEmailAddress]; |
View freeDiskSpace.m
- (uint64_t)freeDiskspace | |
{ | |
uint64_t totalFreeSpace = 0; | |
__autoreleasing NSError *error = nil; | |
NSString *path = [self applicationDocumentsDirectory]; | |
NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:path error: &error]; | |
if (dictionary) { | |
NSNumber *freeFileSystemSizeInBytes = [dictionary objectForKey:NSFileSystemFreeSize]; |
View README.txt
Prefer printf to the C++ iosstream methods? Now you can create a string using printf style format strings, and also append formatted string to existing strings. | |
Inspired by: http://stackoverflow.com/questions/2342162 |
View DavidTop10
David's Top 10: Do That When Writing Swift | |
1) Purchase Dash (OS X and iOS) and get Swift from SwiftDoc.org (invaluable reference, I use it daily!) | |
2) Use Enums for UIView tags and SegmentedControl segments; | |
enum MyViews: Int { case OKButton=1...} then switch MyViews(rawValue: view.tag) | |
also for states (somewhat replaces C's X-Macros, helps during debugging) | |
View HowTo.txt
When I posted this on Apple’s Cocoadev listserver, I never did get pointers to code to convert a NSDictionary to a binary formatted plist, but did get pointers to look at NSPropertyListSerialization - something I had already (mis)read a few times. | |
The description for the dataFromPropertyList class method seems confusing if you don't understand that you can create a property list with no keys: that is, you can create one with a single compliant object, and the key becomes "root". | |
So, in the unlikely event that some else someday has the same mental block, here is actual tested code that takes a NSDictionary and creates a binary plist file: | |
NSDictionary *dict; | |
char *payload = "This is the payload"; | |
dict = [NSDictionary dictionaryWithObjectsAndKeys: |
View MyWebFetcher.m
#if ! __has_feature(objc_arc) | |
#error THIS CODE MUST BE COMPILED WITH ARC ENABLED! | |
#endif | |
static CFArrayRef certs; | |
@implementation MyWebFetcher | |
+ (void)initialize | |
{ |
View Reachability.h
/* | |
File: Reachability.h | |
Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs. | |
Version: 2.2 - ARCified | |
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. | |
("Apple") in consideration of your agreement to the following terms, and your | |
use, installation, modification or redistribution of this Apple software |
View README.txt
Reloading the NIB is expensive. Better to load it once, then instantiate the objects when you need a cell. Note that you can add UIImageViews etc to the nib, even multiple cells, using this method (Apple's "registerNIB" iOS5 allows only one top level object - one UITableViewCell. Bug 10580062 "iOS5 tableView registerNib: overly restrictive" | |
So my code is below - you read in the NIB once (in +initialize like I did or in viewDidload - whatever. From then on, you instantiate the nib into objects then pick the one you need. This is much more efficient than loading the nib over and over. |
NewerOlder