// Set the flag for a block completion handler
#define FLSTART() __block dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
// Set the flag to stop the loop
#define FLEND() dispatch_semaphore_signal(semaphore);
// Wait and loop until flag is set
#define FLWAIT() WAITWHILE(dispatch_semaphore_wait(semaphore, DISPATCH_TIME_NOW))
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 NSDictionary (QuickLook) | |
- (id)debugQuickLookObject | |
{ | |
NSData *data = [NSJSONSerialization dataWithJSONObject:self options:NSJSONWritingPrettyPrinted error:nil]; | |
NSString *JSONString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; | |
NSString *embedHTML = [NSString stringWithFormat:@"<html><head></head><body><pre>%@</pre></body></html>",JSONString]; |
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 sortByProperty<T: NSObject>(array: [T], property: String, ascending: Bool) -> [T] { | |
var sortedBooks = [T](array) | |
sortedBooks.sort { element1, element2 in | |
var value1: AnyObject! = "" | |
var value2: AnyObject! = "" | |
if element1.respondsToSelector(Selector(property)) { | |
value1 = element1.valueForKey(property) |
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
var imageRequestOperationKey = "imageRequestOperationPointer" | |
let imageRequestOperationPointer = UnsafePointer<String>(COpaquePointer(&imageRequestOperationKey)) | |
extension UIImageView { | |
func bw_imageRequestOperation() -> AFHTTPRequestOperation { | |
return objc_getAssociatedObject(self, imageRequestOperationPointer) as AFHTTPRequestOperation | |
} | |
func bw_setImageRequestOperation(operation :AFHTTPRequestOperation?) { |
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
set -ex | |
[ "$ACTION" = build ] || exit 0 | |
[ "$BUILD_VARIANTS" = "normal" ] || exit 0 | |
[ "$CONFIGURATION" = "Release" ] || exit 0 | |
dir="$TEMP_FILES_DIR/disk" | |
dmg="$HOME/Desktop/$PROJECT_NAME.dmg" | |
rm -rf "$dir" |
- To add Settings.bundle in Xcode. Command N and in Resource, choose Settings Bundle .
- Open
Root.plist
in source code, paste the code below to replace it,
<?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>PreferenceSpecifiers</key>
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
#!/usr/bin/env bash | |
rm -rf "${HOME}/Library/Caches/CocoaPods" | |
rm -rf "`pwd`/Pods/" | |
pod update |
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
- (NSData *)AES128EncryptWithData:(NSData *)data { | |
NSUInteger dataLength = [self length]; | |
//See the doc: For block ciphers, the output size will always be less than or | |
//equal to the input size plus the size of one block. | |
//That's why we need to add the size of one block here | |
size_t bufferSize = dataLength + kCCBlockSizeAES128; | |
void *buffer = malloc(bufferSize); |
OlderNewer