Just for Objective-C Program Language
Encoding非常用编码转换
摘要:NSStringEncoding enc = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingISO_2022_JP_2); NSString *result = [[NSString alloc] initWithData:data encoding:enc];
阅读全文
posted @
2014-04-11 10:21
BankFish
阅读(885)
推荐(0)
Block作为参数使用
摘要:// 声明typedef void (^completion)(int intCount, int intSize);void (^completion)(int intCount, int intSize) = ^(int intCount, int intSize) { // Logic Handle};//[instance doSomething:completion];
阅读全文
posted @
2014-04-09 17:11
BankFish
阅读(235)
推荐(0)
UITextField关闭系统自动联想和首字母大写功能
摘要:[_txtFieldsetAutocorrectionType:UITextAutocorrectionTypeNo];[_txtFieldsetAutocapitalizationType:UITextAutocapitalizationTypeNone];
阅读全文
posted @
2014-04-06 22:43
BankFish
阅读(8655)
推荐(2)
截取UIView的高清图片
摘要:UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0); [self.view.layerrenderInContext:UIGraphicsGetCurrentContext()]; UIImage * img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();
阅读全文
posted @
2014-03-06 16:56
BankFish
阅读(315)
推荐(0)
清除UITableView底部多余的分割线
摘要:出处:http://kongbei888.blog.163.com/blog/static/243266132012410104414609/1、加方法-(void)setExtraCellLineHidden: (UITableView *)tableView{UIView *view = [UIView new];view.backgroundColor = [UIColor clearColor];[tableView setTableFooterView:view];[view release];}2、在- (void)viewDidLoad{ [superviewDidLoad];.
阅读全文
posted @
2013-05-02 10:58
BankFish
阅读(6738)
推荐(0)
Objective-C主动抛出异常
摘要:NSException *ex = [[NSException alloc] initWithName:@"MyException" reason:@"b=0" userInfo:nil];@throw(ex);
阅读全文
posted @
2013-04-24 11:12
BankFish
阅读(617)
推荐(1)
iPhone系统音效
摘要:来源:http://iphonedevwiki.net/index.php/AudioServices
阅读全文
posted @
2013-04-23 16:44
BankFish
阅读(346)
推荐(0)
iO网络连接相关笔记
摘要:1. 在SystemConfiguration.famework中提供和联网相关的function, 可用来检查网络连接状态。2. SC(SystemConfiguration)框架中关于测试连接网络状态相关的函数定义在SCNetworkReachability.h文件中,主要函数如下:// 创建测试连接的引用SCNetworkReachabilityRef SCNetworkReachabilityCreateWithAddress(CFAllocatorRef allocator, const struct sockaddr *address);// 根据传入的地址测试连接, 第一参数可以
阅读全文
posted @
2013-04-15 11:59
BankFish
阅读(3233)
推荐(0)
iOS中Lua脚本应用笔记一:脚本概念相关
摘要:脚本(Script): 计算机术语解释为是一条条的文字命令,这些文字命令是可以看到的(如可以用Notepad打开查看、编辑),脚本程序在执行时,是由系统的一个解释器,将其一条条的翻译成机器可识别的指令,并按程序顺序执行。因为脚本在执行时多了一道翻译的过程,所以它比二进制程序执行的效率要稍低一些。 脚本通常可以由应用程序临时调用执行。各类脚本被广泛地应用于网页(Weg Page)设计中,因为脚本不仅可以减小网页的规模和提高网页浏览速度,而且可以丰富网页的表现,如动画、声音等。常见例子为,点击网页上的Email地址时能自动调用Outloook Express或Foxmail这类邮箱软件,即是通..
阅读全文
posted @
2013-04-12 10:14
BankFish
阅读(1929)
推荐(0)
iOS的单例模式
摘要:IOS中的单例模式 在objective-c中要实现一个单例类,至少需要做以下四个步骤: 1、为单例对象实现一个静态实例,并初始化,然后设置成nil, 2、实现一个实例构造方法检查上面声明的静态实例是否为nil,如果是则新建并返回一个本类的实例, 3、重写allocWithZone方法,用来保证其他人直接使用alloc和init试图获得一个新实力的时候不产生一个新实例, 4、适当实现allocWitheZone,copyWithZone,release和autorelease。下面以SurveyRunTimeData为例子:static SurveyRunTimeData *shar...
阅读全文
posted @
2013-04-10 11:59
BankFish
阅读(3596)
推荐(0)
GCD笔记四
摘要:原帖地址:http://www.dreamingwish.com/dream-2012/gcd-four-the-the-odds-and-ends.htmlDispatch Queue挂起dispatch queue可以被挂起和恢复。使用dispatch_suspend函数来挂起,使用 dispatch_resume函数来恢复。这两个函数的行为是如你所愿的。另外,这两个还是也可以用于dispatch source。一个要注意的地方是,dispatch queue的挂起是block粒度的。换句话说,挂起一个queue并不会将当前正在执行的block挂起。它会允许当前执行的block执行完毕,然
阅读全文
posted @
2013-04-09 17:59
BankFish
阅读(242)
推荐(0)
GCD笔记三
摘要:原帖地址:http://www.dreamingwish.com/dream-2012/intro-to-grand-central-dispatch-part-iii-the-dispatch-sources.html何为Dispatch Sources简单来说,dispatch source是一个监视某些类型事件的对象。当这些事件发生时,它自动将一个block放入一个dispatch queue的执行例程中。说的貌似有点不清不楚。我们到底讨论哪些事件类型?下面是GCD 10.6.0版本支持的事件:Mach port send right state changes.Mach port re
阅读全文
posted @
2013-04-09 17:58
BankFish
阅读(200)
推荐(0)
GCD笔记二
摘要:原帖地址:http://www.dreamingwish.com/dream-2012/of-of-of-performance-of-of-of-of-of-of-of-gcd-introduced-ba-the-multi-core.html概念为了在单一进程中充分发挥多核的优势,我们有必要使用多线程技术(我们没必要去提多进程,这玩意儿和GCD没关系)。在低层,GCD全局dispatch queue仅仅是工作线程池的抽象。这些队列中的Block一旦可用,就会被dispatch到工作线程中。提交至用户队列的Block最终也会通过全局队列进入相同的工作线程池(除非你的用户队列的目标是主线程,但
阅读全文
posted @
2013-04-09 17:57
BankFish
阅读(237)
推荐(0)
GCD笔记一
摘要:原帖地址:http://www.dreamingwish.com/dream-2012/of-of-of-of-gcd-introduced-1-basic-concepts-in-and-the-dispatch-queue.htmlGCD(Grand Central Dispatch) : 低层API, 提供新的并发程序编写方法,类似NSOperationQueue, 允许程序将任务切分为多个单一任务后提交至工作队列并发或串行执行。 比之NSOperationQueue更底层更高效,不是Cocoa Framework的一部分。 提供高度集成的事件控制系统,可设置句柄来响应文件描述符、...
阅读全文
posted @
2013-04-09 17:23
BankFish
阅读(197)
推荐(0)
使用CTSettingCopyMyPhoneNumber()函数获取电话号码的注意事项
摘要:1. 首先要导入CoreTelephony的Private Framework;2. 在导入CoreTelephony后使用CTSettingCopyMyPhoneNumber()将出现以下警告:Semantic IssueImplicit declaration of function 'CTSettingCopyMyPhoneNumber' is invalid in C99解决方法为在使用CTSettingCopyMyPhoneNumber()的.m文件中加入如下语句:extern NSString *CTSettingCopyMyPhoneNumber();
阅读全文
posted @
2013-04-08 10:05
BankFish
阅读(3421)
推荐(0)
Reachability.h文件在iOS6中出现的警告
摘要:Reachability.h文件在iOS6中会出现这样的一个Warning:SemanticDeclaration of 'struct sockaddr_in' will not be visible outside of this function.解决方法是引入以下的Header文件:#import <netinet/in.h>
阅读全文
posted @
2013-04-08 09:36
BankFish
阅读(902)
推荐(0)
监听iPhone系统电话事件
摘要:1. 关于iPhone系统电话事件监听#import <CoreTelephony/CTCallCenter.h>#import <CoreTelephony/CTCall.h>- (void)listenCallEvent{ CTCallCenter *callCenter = [[CTCallCenter alloc] init]; [callCenter setCallEventHandler:^(CTCall *call) { if (call.callState == CTCallStateConnected) { NSL...
阅读全文
posted @
2013-03-31 21:17
BankFish
阅读(990)
推荐(0)
UIModalPresentationFormSheet风格下的键盘隐藏
摘要:1. 在UIModalPresentationFormSheet(iPad device, without a UINavigationController)下的视图中,如果使用[inputView resignFirstResponder];是不能把Keyboard收起的,需要使用以下的方式:A: @try { Class UIKeyboardImpl = NSClassFromString(@"UIKeyboardImpl"); id activeInstance = [UIKeyboardImpl performSelector:@selector(activeIns
阅读全文
posted @
2013-03-30 22:16
BankFish
阅读(1755)
推荐(0)
Objective-C学习笔记十四_F
摘要:Chapter 12 : 归档1. 归档 :-> 定义: 用某种格式来保存一个或多个对象,以便以后还原这些对象的过程。其中包括将多个对象写入文件,以便以后读回该对象。-> 方法:(1)属性列表; (2)带键值的编码。2. 属性列表:若对象是NSString, NSDictionary, NSArray, NSData, NSNumber对象时,可以使用writeToFile:atomically:方法将数据写入到文件中,是以属性列表的形式写到文件中的。PS : 参数atomically为YES, 表示先将数据写到临时备份文件中,一旦成功,再转移到文件中。示例代码:#import &
阅读全文
posted @
2012-09-28 17:48
BankFish
阅读(500)
推荐(0)
Objective-C学习笔记十三
摘要:Chapter 11 : 复制对象1. 回顾继承部分的代码如下: 1 // XYPoint类声明 2 // XYPoint.h文件 3 4 #import <Foundation/Foundation.h> 5 6 @interface XYPoint : NSObject 7 { 8 int x; 9 int y;10 }11 12 @property int x;13 @property int y;14 15 - (void)setX:(int)xVal andY:(int)yVal;16 17 @end 1 // XYPoint类定义 2 // XYPoint.m文...
阅读全文
posted @
2012-09-28 16:45
BankFish
阅读(562)
推荐(0)