Fork me on GitHub

2012年3月7日

摘要: language backgroundrun­timethreadrun­loopdel­e­gate, protocolrespon­der chainmem­ory managementclass heritage and categorydesign patternthinking before asking首先请谅解我可能使用很多英文,毕竟英文资料将来会是你的主要资料来源。在你继续深入学习之前,请停下脚步弄清这些问题。如果你是新手,这个教程不要希望一次能看的非常透彻,学一定阶段反回来再看看又会有新的体会的。在你继续深入学习之前 阅读全文
posted @ 2012-03-07 23:49 pengyingh 阅读(593) 评论(0) 推荐(0)
摘要: 下面是应用动态识别时所用到的方法:-(BOOL)isKindOfClass: classObj是否是其子孙或一员-(BOOL)isMemberOfClass: classObj是否是其一员-(BOOL)respondsToSelector: selector是否有这种方法+(BOOL)instancesRespondToSelector: selector类的对象是否有这种方法-(id)performSelector: selector执行对象的方法通过下面的代码可以更清楚地理解动态类型的使用:import "Square.h"#import "Rectangle 阅读全文
posted @ 2012-03-07 20:16 pengyingh 阅读(336) 评论(0) 推荐(0)
摘要: Posing有点像类别,但不太一样。它允许你扩充一个类,并且全面性地扮演(pose)这个超类。例如:你有一个扩充NSArry的NSArrayChild对象。如果你让NSArrayChild扮演NSArry,则在你的代码中所有的NSArray都会自动被替代为NSArrayChild.@interface FractionB: Fraction-(void) print;@end@implementation FractionB-(void) print {printf( "(%i/%i)", numerator, denominator );}@endFraction.min 阅读全文
posted @ 2012-03-07 20:12 pengyingh 阅读(219) 评论(0) 推荐(0)
摘要: http://blog.myspace.cn/jasonliu651/category/719416.aspx(强人进阶帖)http://book.51cto.com/art/201003/186356.htm(AppStore掘金——iPhone SDK应用程序开发)Cocoa夜未央-视频http://www.apple.com.cn/developer/mac/library/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/chapter_6_section_3.html(消息转发,多继承, 运行时系统消息处理及交互)htt 阅读全文
posted @ 2012-03-07 16:33 pengyingh 阅读(392) 评论(0) 推荐(0)
摘要: 加入three20的总结:1) 将three20放在工程文件夹下,以边Reveal in Finder能快速找到three20和每次编译能快速找到框架。2) 将Three20.xcodeproj加入到工程中,确保“copy items”没被选中,“Reference Type”是“Ralative to project”状态,点击添加。3) 双击Three20.xcodeproj,将Three20项目中的dependencies(这个文件夹下有6个工程文件)拖进你现有的项目中,确保“copy items”没被选中,“Reference Type”是“Ralative to project”状态 阅读全文
posted @ 2012-03-07 16:30 pengyingh 阅读(467) 评论(0) 推荐(0)
摘要: block 是Apple在 GCC 4.2 中扩充的新语法特性,其目的是支持多核并行编程。我们可以将 dispatch_queue 与 block 结合起来使用,方便进行多线程编程。1,实验工程准备在XCode4.0 中,我们建立一个 Mac OS X Application 类型的 Command Line Tool,在 Type 里面我们选择 Foundation 就好,工程名字暂且为 StudyBlocks.默认生成的工程代码 main.m 内容如下:int main(int argc, const char * argv[]){NSAutoreleasePool * pool = [[ 阅读全文
posted @ 2012-03-07 16:22 pengyingh 阅读(426) 评论(0) 推荐(0)
摘要: 因 为iOS SDK相对比较底层,所以开发者就得受累多做一些体力活。不过幸运的是,有很多第三方的类库可以用来简化很多不必要的工作。笔者整理了一下在本人学习过程 中用到的一些比较有用Objective-C开源类库,既是做一个总结,同时也希望通过这些分享,能提高各位的开发效率。KissXml——xml解析库相关教程:http://www.iteye.com/topic/625849http://sencho.blog.163.com/blog/static/83056228201151743110540/很方便的一个xml解析器,支持Xpath查询。skpsmtpmessage——Quick SM 阅读全文
posted @ 2012-03-07 16:17 pengyingh 阅读(197) 评论(0) 推荐(0)
摘要: 深入理解iPhone静态库(手把手教你iphone开发-基础篇)作者:孙东风2009-11-20(请尊重作者劳动成果,转载务必注明出处)在实际的编程过程中,通常会把一些公用函数制成函数库,供其它程序使用,一则提搞了代码的复用;二则提搞了核心技术的保密程度。所以在实际的项目开发中,经常会使用到函数库,函数库分为静态库和动态库两种。和多数人所熟悉的动态语言和静态语言一样,这里的所谓静态和动态是相对编译期和运行期的:静态库在程序编译时会被链接到目标代码中,程序运行时将不再需要改静态库;而动态库在程序编译时并不会被链接到目标代码中,只是在程序运行时才被载入,因为在程序运行期间还需要动态库的存在。iPh 阅读全文
posted @ 2012-03-07 16:14 pengyingh 阅读(223) 评论(0) 推荐(0)
摘要: UIView *flashView = [[UIView alloc] initWithFrame:[[self view] frame]]; [flashView setBackgroundColor:[UIColor whiteColor]]; [[[self view] window] addSubview:flashView]; [UIView animateWithDuration:.4f animations:^{ [flashView setAlpha:0.f]; } completion:^(BOOL finished){ [flashView removeFromSupe.. 阅读全文
posted @ 2012-03-07 16:04 pengyingh 阅读(462) 评论(0) 推荐(0)
摘要: 1、 drawRect: is invoked automaticall,never call it directly!!2、 When a view needs to be redrawn,use: - (void)setNeedsDisplay;3、在非主线程中调用,需使用如下方法: - (void)performSelector:(SEL)aSelector onThread:(NSThread *)thr withObject:(id)arg waitUntilDone:(BOOL)wait - (void)performSelectorOnMainThread:(SEL)aSele. 阅读全文
posted @ 2012-03-07 16:02 pengyingh 阅读(6014) 评论(0) 推荐(0)
摘要: 原文作者:Matt Gallagher原文链接:http://cocoawithlove.com/2010/09/substituting-local-data-for-remote.html翻译:http://disanji.net/2010/11/24/substituting-local-data-for-remote-html/cachedResponseForRequestCocoaCocoaWithLoveiOSMatt GallagherNSURLCacheUIWebViewUIWebViewDelegate在研究苹果官方Demo:XMLPerformance 的时候,对NSUR 阅读全文
posted @ 2012-03-07 16:00 pengyingh 阅读(9437) 评论(1) 推荐(0)
摘要: 知识点介绍Key-Value Observing (简写为KVO):当指定的对象的属性被修改了,允许对象接受到通知的机制。每次指定的被观察对象的属性被修改的时候,KVO都会自动的去通知相应的观察者。KVO的优点:当 有属性改变,KVO会提供自动的消息通知。这样的架构有很多好处。首先,开发人员不需要自己去实现这样的方案:每次属性改变了就发送消息通知。这是KVO 机制提供的最大的优点。因为这个方案已经被明确定义,获得框架级支持,可以方便地采用。开发人员不需要添加任何代码,不需要设计自己的观察者模型,直接可 以在工程里使用。其次,KVO的架构非常的强大,可以很容易的支持多个观察者观察同一个属性,以及 阅读全文
posted @ 2012-03-07 15:25 pengyingh 阅读(49950) 评论(0) 推荐(3)
摘要: iPhone wifi使用socket连接Internet1.使用AsyncSocket(http://code.google.com/p/cocoaasyncsocket/)来做为Socket的一个基础库.2.在该库里面提供了一个EchoServer,我们可以利用这个程序直接在MAC系统上面运行一个测试服务器起来.3.根据AsyncSocket(http://code.google.com/p/cocoaasyncsocket/wiki/iPhone)的WIKI将AsyncSocket加入到iPhone的工程里面,记得将TARGET_OS_IPHONE这个宏在工程上面给定义一下.4.编译工程 阅读全文
posted @ 2012-03-07 15:15 pengyingh 阅读(1896) 评论(0) 推荐(0)
摘要: 苹果SDK自带的就有密码保护,使用方法很简单,如下:1、引入Security.frameWork框架。2、引入头文件:SFHKeychainUtils.h.3、存密码:[SFHFKeychainUtilsstoreUsername:@"dd"andPassword:@"aa"forServiceName:SERVICE_NAMEupdateExisting:1error:nil];[SFHFKeychainUtilsdeleteItemForUsername:@"dd"andServiceName:SERVICE_NAMEerror: 阅读全文
posted @ 2012-03-07 15:09 pengyingh 阅读(149) 评论(0) 推荐(0)
摘要: 最近看这个比较多人用到,以前有使用过,现在,粘过来给大伙看看.注意:UIImageView的大小只能跟图片一样大.要不然取色不对.- (UIColor *) getPixelColorAtLocation:(CGPoint)point { UIColor* color = nil; CGImageRef inImage = self.image.CGImage; // Create off screen bitmap context to draw the image into. Format ARGB is 4 bytes for each pixe... 阅读全文
posted @ 2012-03-07 15:00 pengyingh 阅读(1216) 评论(0) 推荐(0)
摘要: 核心函数是:CGContextAddArc(CGContextRef c, CGFloat x, CGFloat y, CGFloat radius, CGFloat startAngle, CGFloat endAngle, int clockwise) * CGContextRef: 图形上下文 * x,y: 开始画的坐标 * radius: 半径 * startAngle, endAngle: 开始的弧度,结束的弧度 * clockwise: 画的方向(顺时针,逆时针)有了这个函数可以画出任意扇形,所以饼图也不再话下.#define PI 3.14159265358979323... 阅读全文
posted @ 2012-03-07 14:48 pengyingh 阅读(584) 评论(0) 推荐(0)
摘要: http://www.devdiv.com/thread-48165-1-1.htmlpart 1--入门:1. xcode 版本下载 以及 iphone sdk 下载:最新版本在此下载:http://developer.apple.com/devcenter/ios/index.action其他版本请看http://connect.apple.com/cgi-bin ... 1.0.1.1.0.3.3.3.3.12. 入门教程:http://www.devdiv.com/thread-46499-1-1.htmlpart 2--代码、例程:1. iphone编码转换方法:http://www 阅读全文
posted @ 2012-03-07 14:43 pengyingh 阅读(314) 评论(0) 推荐(0)
摘要: 1、获取iPod歌曲列表:有两种方式:(1),使用picker选取MPMediaPickerController*picker =[[MPMediaPickerControlleralloc]initWithMediaTypes:MPMediaTypeMusic];picker.delegate=self;picker.allowsPickingMultipleItems=YES;picker.prompt=@"新增歌曲";[selfpresentModalViewController: pickeranimated:YES];[pickerrelease];回调方法:- 阅读全文
posted @ 2012-03-07 14:38 pengyingh 阅读(367) 评论(0) 推荐(0)
摘要: 在图生上处理字符的时候,需要得到字符串所占位置长度。这长度与字体相关。下面的方法判断200像素的长度内是否可以以最小字体为15号字体来显示字符串。str为你要显示的字符串。UIFont *font = [UIFont fontWithName:@"DINNextLTPro-Bold" size:20]; UILabel *label = [[UILabel alloc] init]; label.lineBreakMode = UILineBreakModeCharacterWrap; label.numberOfLines = 1; label.font = font.. 阅读全文
posted @ 2012-03-07 14:34 pengyingh 阅读(3473) 评论(0) 推荐(0)
摘要: - (float)volume{return [[MPMusicPlayerController applicationMusicPlayer] volume];}- (void)setVolume:(float)newVolume{[[MPMusicPlayerController applicationMusicPlayer] setVolume:newVolume];} 阅读全文
posted @ 2012-03-07 14:33 pengyingh 阅读(154) 评论(0) 推荐(0)

导航