Skip to content

Instantly share code, notes, and snippets.

@xiangyuan
xiangyuan / gist:2973424
Created June 22, 2012 15:21 — forked from pokeb/gist:150447
An example showing how to manage a queue with ASIHTTPRequest
//
// MyController.h
//
// Created by Ben Copsey on 20/07/2009.
// Copyright 2009 All-Seeing Interactive. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GHUnit/GHUnit.h>
@class ASINetworkQueue;
@xiangyuan
xiangyuan / gist:3077067
Created July 9, 2012 15:07
jsonkit使用示例
// Do any additional setup after loading the view, typically from a nib.
NSURLRequest * request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.imdida.org/json/city/ip"]];
NSURLResponse * response;
NSError *error;
NSData * jsonData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSDictionary * results = [jsonData objectFromJSONData];
NSLog(@"%@",[results objectForKey:@"ip"]);
@xiangyuan
xiangyuan / ARCHelper.h
Created July 23, 2012 02:22 — forked from nicklockwood/ARCHelper.h
ARC Helper
//
// ARC Helper
//
// Version 2.1
//
// Created by Nick Lockwood on 05/01/2012.
// Copyright 2012 Charcoal Design
//
// Distributed under the permissive zlib license
// Get the latest version from here:
@xiangyuan
xiangyuan / gist:3164566
Last active October 7, 2015 12:27
ios中ViewController加载过程描述
iewController的初始化:
从Storyboards中加载的时候,会调用initWithCode,如果不存在则调用init。之后对里面的每个对象调用awakeFromNib方法。
从内存中alloc出来的情况下,调init方法。
ViewController查找与其关联的view,其顺序是:
1 先判断子类是否重写了loadView,如果有直接调用。之后调viewDidLoad完成View的加载。
2 如果是外部通过调用initWithNibName:bundle指定nib文件名的话,ViewController记载此nib来创建View。
3 如果initWithNibName:bundle的name参数为nil,则ViewController会通过以下两个步骤找到与其关联的nib。
A 如果类名包含Controller,例如ViewController的类名是MyViewController,则查找是否存在MyView.nib;
@xiangyuan
xiangyuan / gist:3175149
Created July 25, 2012 08:43
iphone界面
http://developer.apple.com/library/ios/documentation/userexperience/conceptual/mobilehig/MobileHIG.pdf
1.状态栏(20)
[1]:http://www.apple.com.cn/developer/iphone/library/documentation/UserExperience/Conceptual/MobileHIG/art/ui_statusbartypes.jpg
高度:20px
颜色:灰色(默认)、黑色、半透明黑色(α值为0.5的黑色)3种可选
@xiangyuan
xiangyuan / gist:3180022
Created July 26, 2012 03:10
google语音
http://developer.apple.com/library/ios/#samplecode/SpeakHere/Listings/AudioViews_AQLevelMeter_mm.html
@xiangyuan
xiangyuan / gist:3181284
Created July 26, 2012 09:55
UIimage的拉伸扩展
UIImage *rawBackground = [UIImage imageNamed:@"picture"];
UIImage *background = [rawBackground stretchableImageWithLeftCapWidth:13 topCapHeight:22];
UIImageView *imageView = [[UIImageView alloc] initWithImage:background];
imageView.frame = CGRectMake(0, 0, containerView.frame.size.width, containerView.frame.size.height);
imageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
@xiangyuan
xiangyuan / gist:3215195
Created July 31, 2012 08:56
ios static library使用注意
注意引入的static library在编译时需要进行 _all_load -Objc 等linker flag注意
@xiangyuan
xiangyuan / gist:3254727
Created August 4, 2012 05:13
git config params
Global ignore file:
echo ".DS_Store" >> ~/.gitignore
git config --global core.excludesfile ~/.gitignore
SVN-like shortcuts for often used commands:
git config --global alias.st status
git config --global alias.ci commit
git config --global alias.co checkout
git config --global alias.br branch
@xiangyuan
xiangyuan / gist:3270114
Created August 6, 2012 04:05
php数据覆值copy与reference
PHP array assignment (PHP array assignment is copy by value)
$a = array('a', 'b', 'c');
$a2 = $a;
上面的直接覆值是一种copy机制,会产生两个不同的数组供使用
A duplicate copy of the array (copy by value) is made
Change in one array have no impact on other
$a = array("original");
$b = $a;
$a[0] = "new"; // $b[0] will remain as "original"