##XXAppDelegate.m, XXSomeView.m, some other object, etc##
...
[[XXSomeSingletonController sharedInstance] doThatThing];
...
##XXSomeSingletonControllerObserver.h##
@protocol XXSomeSingletonControllerObserver
##XXAppDelegate.m, XXSomeView.m, some other object, etc##
...
[[XXSomeSingletonController sharedInstance] doThatThing];
...
##XXSomeSingletonControllerObserver.h##
@protocol XXSomeSingletonControllerObserver
#import "Foo.h" | |
static dispatch_once_t FooSharedDispatchOnceToken; | |
static Foo *FooSharedInstance; | |
+ (void)prepareService | |
{ | |
[self fetchSharedServiceAndInitialize:YES]; | |
} |
static void *kFOOClassKVOContext = &kFOOClassKVOContext; | |
@implementation FOOClass | |
- (void)addKVOObservers | |
{ | |
[self.property addObserver:self forKeyPath:@"someKeyPath" options:0 context:kFOOClassKVOContext]; | |
} | |
- (void)removeKVOObservers |
Copyright (c) <year> Josh Avant | |
Permission is hereby granted, free of charge, to any person obtaining a | |
copy of this software and associated documentation files (the "Software"), | |
to deal in the Software without restriction, including without limitation | |
the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
and/or sell copies of the Software, and to permit persons to whom the | |
Software is furnished to do so, subject to the following conditions: | |
The above copyright notice and this permission notice shall be included in |
The recommended way to keep a long-term reference to a particular record is to store the first and last name, or a hash of the first and last name, in addition to the identifier. When you look up a record by ID, compare the record’s name to your stored name. If they don’t match, use the stored name to find the record, and store the new ID for the record.
-from Address Book Programming Guide for iOS, Using Record Identifiers, 2nd paragraph
// requires UICKeyChainStore lib | |
NSString *uniqueIdentifier; | |
#if TARGET_IPHONE_SIMULATOR | |
uniqueIdentifier = @"SIMULATOR"; | |
#else | |
uniqueIdentifier = [UICKeyChainStore stringForKey:@"UUID" service:@"joshavant"]; | |
if(![uniqueIdentifier length] > 0) |
func alertControllerToSelectContactMethod() -> UIAlertController { | |
let controller = UIAlertController(title: "How do you want to contact \(firstName.value)?", message: "", preferredStyle: .ActionSheet) | |
let methodsAndHandlers = contactMethodsAndHandlers() | |
if (methodsAndHandlers.count == 0) { | |
let action = UIAlertAction(title: NSLocalizedString("No Contact Info Found", comment: ""), style: .Default, handler: nil) | |
action.enabled = false | |
controller.addAction(action) |
This document describes how to configure your scroll views in IB, so that their insets are configured to accomodate coverage by UINavigationBar
and UITabBar
.
A common reason for wanting this is to allow these views to configured as 'translucent', while scroll view content scrolls beneath them.
This guide is broken up into two types of view configurations...
UIViewController
's view
UIViewController
's view
import Foundation | |
protocol Pageable { | |
typealias PagedContentType | |
var pageLimit: Int { get set } | |
var pageOffset: Int { get set } | |
func getPage(limit limit: Int, offset: Int, completion: (result: [PagedContentType]?, error: NSError?) -> Void) | |
mutating func nextPage(completion: (result: [PagedContentType]?, error: NSError?) -> Void) |
// Broken on 9.2, Worked on 9.1 | |
let keysToFetch = [CNContactGivenNameKey, CNContactFamilyNameKey, CNContactPhoneNumbersKey, CNContactEmailAddressesKey] | |
// Works on 9.2 + 9.1 | |
let keysToFetch = [CNContactPhoneNumbersKey, CNContactEmailAddressesKey, CNContactFormatter.descriptorForRequiredKeysForStyle(.FullName)] |