This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// TCHorizontalSelectorView.m | |
// TwinCodersLibrary | |
// | |
// Created by Guillermo Gutiérrez on 16/01/13. | |
// Copyright (c) 2013 TwinCoders S.L. All rights reserved. | |
// | |
#import <UIKit/UIKit.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Most NSString instances will actually be __NSCFString instances, so here are both NSString and __NSCFString implementations. | |
* If you know how to create an NSString instance whose class is actually NSString please let me know. | |
* Other possible concrete subclasses of NSString are: NSConstantString, __NSCFConstantString, NSPathStore2, NSSimpleCString and __NSLocalizedString. | |
*/ | |
// CoreFoundation.framework 635.19.0 (Mac OS X 10.7.3) | |
@implementation NSObject | |
- (BOOL) isNSString__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
#import <ImageIO/ImageIO.h> | |
#import <MobileCoreServices/MobileCoreServices.h> | |
static UIImage *frameImage(CGSize size, CGFloat radians) { | |
UIGraphicsBeginImageContextWithOptions(size, YES, 1); { | |
[[UIColor whiteColor] setFill]; | |
UIRectFill(CGRectInfinite); | |
CGContextRef gc = UIGraphicsGetCurrentContext(); | |
CGContextTranslateCTM(gc, size.width / 2, size.height / 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation NSString (Range) | |
- (NSArray *)rangesOfString:(NSString *)substring { | |
if (self.length == 0 || substring.length == 0) | |
return @[]; | |
NSRange searchRange = NSMakeRange(0, self.length - 1); | |
NSMutableArray *ranges = [@[] mutableCopy]; | |
while (searchRange.location < self.length) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIDevice *device = [UIDevice currentDevice]; //Get the device object | |
[device beginGeneratingDeviceOrientationNotifications]; //Tell it to start monitoring the accelerometer for orientation | |
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; //Get the notification centre for the app | |
[nc addObserver:self //Add yourself as an observer | |
selector:@selector(orientationChanged:) | |
name:UIDeviceOrientationDidChangeNotification | |
object:device]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
【iOS中有关键盘事件】 | |
let notificationCenter = NSNotificationCenter.defaultCenter() | |
notificationCenter.addObserver(self, selector: "adjustForKeyboard:", name: UIKeyboardWillHideNotification, object: nil) | |
notificationCenter.addObserver(self, selector: "adjustForKeyboard:", name: UIKeyboardWillChangeFrameNotification, object: nil) | |
func adjustForKeyboard(notification: NSNotification) { | |
let userInfo = notification.userInfo! | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.m | |
// AVPlayerCaching | |
// | |
// Created by Anurag Mishra on 5/19/14. | |
// Sample code to demonstrate how to cache a remote audio file while streaming it with AVPlayer | |
// | |
#import "ViewController.h" | |
#import <AVFoundation/AVFoundation.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func hierarchyOfView(_ view: UIView, level: Int = 1) { | |
let subviews = view.subviews | |
if subviews.isEmpty { return } | |
for subview in subviews { | |
var blank = "" | |
for _ in 1..<level { | |
blank += "-" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
public class Storage { | |
fileprivate init() { } | |
enum Directory { | |
// Only documents and other data that is user-generated, or that cannot otherwise be recreated by your application, should be stored in the <Application_Home>/Documents directory and will be automatically backed up by iCloud. | |
case documents | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
infix operator ???: NilCoalescingPrecedence | |
public func ???<T>(optional: T?, defaultValue: @autoclosure () -> String) -> String { | |
switch optional { | |
case let value?: | |
return String(describing: value) | |
case nil: | |
return defaultValue() | |
} | |
} |
OlderNewer