Skip to content

Instantly share code, notes, and snippets.

/**
Provides the ability to verify key paths at compile time.
If "keyPath" does not exist, a compile-time error will be generated.
Example:
// Verifies "isFinished" exists on "operation".
NSString *key = SQKeyPath(operation, isFinished);
// Verifies "isFinished" exists on self.
@xdream86
xdream86 / HUD.h
Created December 21, 2013 07:56
使用MBProgressHUD的便利方法
#import <Foundation/Foundation.h>
#import "MBProgressHUD.h"
@interface HUD : NSObject
+(MBProgressHUD*)showUIBlockingIndicator;
+(MBProgressHUD*)showUIBlockingIndicatorWithText:(NSString*)str;
+(MBProgressHUD*)showUIBlockingIndicatorWithText:(NSString*)str withTimeout:(int)seconds;
+(MBProgressHUD*)showUIBlockingProgressIndicatorWithText:(NSString*)str andProgress:(float)progress;
@xdream86
xdream86 / ImagePreDeCompresser.h
Last active December 31, 2015 20:19
解决在UIScrollView及其子类中浏览大图片卡顿问题的示例代码
//
// ImagePreDeCompresser.h
// PreDecompressionImage
//
// Created by Aegaeon on 12/20/13.
// Copyright (c) 2013 Aegaeon. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (nonatomic, strong) CABasicAnimation *animationCopy;
@end
@xdream86
xdream86 / NSString+XMLInvalidateCharactersEscaper.h
Last active December 29, 2015 17:19
xml非法字符过滤
#import <Foundation/Foundation.h>
@interface NSString (XMLInvalidateCharactersEscaper)
/**
*
+------------+------------+------------+
| 禁用字符 | 转义字符 | 说明 |
+------------+------------+------------+
| < | &lt; | 小于 |
@xdream86
xdream86 / NSString+XMLInvalidateCharactersEscaper.m
Last active December 29, 2015 17:19
xml非法字符过滤
#import "NSString+XMLInvalidateCharactersEscaper.h"
#import <objc/runtime.h>
static void *CustomObjectKey;
@implementation NSString (XMLInvalidateCharactersEscaper)
/*
* category中使用property的示例
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
{
size_t num_locations = 2;
CGFloat locations[2] = {0.1, 0.9}; // 突出一个聚焦点
CGFloat colorComponents[8] = { 68.0/255.0, 68.0/255.0, 68.0/255.0, 1.0,
32.0/255.0, 36.0/255.0, 41.0/255.0, 1.0 };
platform :ios, '6.0'
pod 'AFNetworking', '1.2.0'
pod 'FPPopover', :git => 'https://github.com/50pixels/FPPopover.git'
UIImage *grayImage(UIImage *source)
{
int width = source.size.width;
int height = source.size.height;
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();
CGContextRef context = CGBitmapContextCreate (nil,
width,
height,
APP = MyProject
WORKSPACE = MyProject
CONFIG = Release
SCHEME = MyProject
# iMessage addresses list seperated with white space
IMSG_LIST = xdreamarshal@gmail.com
# Comment the following line if you prefer Bonjour Network
# BASE_URL = http://ota.nsnotfound.com