January 6, 2013
I recently saw a post on Twitter from @chpwn that described the alogorithm that Apple uses for its “rubber band” or “bungee” scrolling.
b = (1.0 – (1.0 / ((x * c / d) + 1.0))) * d
| - (void)loadCameraRollAssetToInstagram:(NSURL*)assetsLibraryURL andMessage:(NSString*)message | |
| { | |
| NSString *escapedString = [assetsLibraryURL.absoluteString urlencodedString]; | |
| NSString *escapedCaption = [message urlencodedString]; | |
| NSURL *instagramURL = [NSURL URLWithString:[NSString stringWithFormat:@"instagram://library?AssetPath=%@&InstagramCaption=%@", escapedString, escapedCaption]]; | |
| [[UIApplication sharedApplication] openURL:instagramURL]; | |
| } |
| #import <UIKit/UIKit.h> | |
| #import <objc/runtime.h> | |
| // Hook with ObjC runtime functions | |
| %config(generator=internal) | |
| // New methods created below | |
| @interface UIGestureRecognizer () | |
| + (void)hs_beginForcingAllNewGestureRecognizersToAllowPencilInput; | |
| + (void)hs_endForcingAllNewGestureRecognizersToAllowPencilInput; |
| extension NSView { | |
| var snapshot: NSImage { | |
| guard let bitmapRep = bitmapImageRepForCachingDisplayInRect(bounds) else { return NSImage() } | |
| bitmapRep.size = bounds.size | |
| cacheDisplayInRect(bounds, toBitmapImageRep: bitmapRep) | |
| let image = NSImage(size: bounds.size) | |
| image.addRepresentation(bitmapRep) | |
| return image | |
| } | |
| } |
| // | |
| // DON'T do this, or else you risk a deadlock (e.g., by accidentally performing it in a different order somewhere) | |
| // | |
| dispatch_async(firstQueue, ^{ | |
| dispatch_sync(secondQueue, ^{ | |
| // code requiring both queues | |
| }); | |
| }); |
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <!-- iOS 10, macOS Sierra, and friends bring a new logging subsystem that's | |
| supposed to scale from the kernel, up to frameworks, and up to apps. It defaults | |
| to a more regimented, privacy-focused approach that large apps and complex | |
| systems need. | |
| It, along with Activity Tracing introduced in iOS 8 and macOS Yosemite and the | |
| Console app in macOS Sierra, hope to help you graduate from caveman debugging to |
Author: Chris Lattner
| import UIKit | |
| /// A validation rule for text input. | |
| public enum TextValidationRule { | |
| /// Any input is valid, including an empty string. | |
| case noRestriction | |
| /// The input must not be empty. | |
| case nonEmpty | |
| /// The enitre input must match a regular expression. A matching substring is not enough. | |
| case regularExpression(NSRegularExpression) |
If you work on a Swift project that follows the Model-View-ViewModel (MVVM) architecture or similar, you may want to jump to counterpart in Xcode from your view to your model, and then to your view model. (ie. by using Ctrl+Cmd+Up and Ctrl+Cmd+Down).
You can do this in recent versions of Xcode by setting a configuration default.
From a terminal, just type this command and press Enter:
defaults write com.apple.dt.Xcode IDEAdditionalCounterpartSuffixes -array-add "ViewModel" "View"