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 <objc/runtime.h> | |
void dumpInheritance(Class cls) { | |
do { | |
NSLog(@"%@", cls); | |
} while ((cls = class_getSuperclass(cls)) != [NSObject class]); | |
NSLog(@" = = %@ ends", @(__PRETTY_FUNCTION__)); | |
} |
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
, . | |
, / . | |
, / .- . | |
. .- .- | |
./ .-- ... | |
.-------- * .-- | |
/ ....... | |
, .. | |
........ ---- | |
. --.. |
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
// | |
// dispatch-timer.c | |
// | |
// Created by Shon Frazier on 4/22/13. | |
// Copyright (c) 2013 Shon Frazier. All rights reserved. | |
// | |
#include <stdio.h> | |
#include <dispatch/dispatch.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
<!-- sudo DailySoftwareUpdate.plist /Library/LaunchDaemons/ --> | |
<!-- sudo launchctl load /Library/LaunchDaemons/DailySoftwareUpdate.plist --> | |
<?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"> | |
<dict> | |
<key>Label</key> | |
<string>DailySoftwareUpdate</string> |
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
void dispatch_wait_while(dispatch_wait_condition_t condition_block, dispatch_time_t interval, dispatch_wait_completion_t completion_block) { | |
if ( !condition_block ) return; | |
if ( !interval ) return; | |
if ( !completion_block ) return; | |
dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dispatch_get_current_queue()); | |
dispatch_source_set_timer(timer, DISPATCH_TIME_NOW, interval, 0.25*NSEC_PER_SEC); | |
dispatch_source_set_event_handler(timer, ^{ | |
if (!condition_block()) { | |
dispatch_source_cancel(timer); |
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
char *cString = "CHS - 中设置了私人内容文件夹 您可以随时访问此文件夹。.pdf"; | |
NSUInteger sLen = strlen(cString); | |
NSString *wrongString = [NSString stringWithFormat:@"%s", cString]; | |
NSLog(@"%@", wrongString); // CHS - 中设置了私人内容文件夹 您可以随时访问此文件夹。.pdf | |
NSString *rightString = [[NSString alloc] initWithBytes:cString length:sLen encoding:NSUTF8StringEncoding]; | |
NSLog(@"%@", rightString); // CHS - 中设置了私人内容文件夹 您可以随时访问此文件夹。.pdf |
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
Class thisClass = [self class]; | |
BOOL conforms = class_conformsToProtocol(thisClass, @protocol(NSObject)); | |
XCTAssert(!conforms, @"*gasp*"); |
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
typedef enum { | |
StyleCircle = 'circ', | |
StylePie = '3.14', | |
StylePolygon = 'poly', | |
} Style; |
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
enum UTF8SequenceLength { | |
Bytes1 = 0, | |
Bytes2 = 0b11000000, | |
Bytes3 = 0b11100000, | |
Bytes4 = 0b11110000, | |
BytesErr = 0b10000000, | |
}; | |
enum UTF8ParsingMode { | |
UTF8ParsingModeNone = 0, |
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
// Playground - noun: a place where people can play | |
import Cocoa | |
let polyPath = NSBezierPath() | |
var sides = 8 | |
var 𝛉 = 0.0 | |
var 𝜋 = 3.14159 | |
var 𝜋2 = 2*𝜋 |
OlderNewer