摘要: 1.字符与字符串 用单引号引起的一个字符实际上代表一个整数,整数值对应于该字符在编译器采用的字符集中的序列值。因此,对于采用ASCII字符集的编译器而言,'a'的含义与0141(八进制)或者97(十进制)严格一致。 用双引号引起的字符串,代表的却是一个指向无名数组起始字符的指针,该数组被双引号之间的字符以及一个额外的二进制为零的字符'\0'初始化。 下面的这个语句: printf("Hello world\n");与 char hello[] = {'H', 'e', 'l', 'l&# 阅读全文
posted @ 2013-02-02 17:44 gagag 阅读(173) 评论(0) 推荐(0) 编辑
摘要: http://bbs.weiphone.com/read-htm-tid-2323882.html 阅读全文
posted @ 2013-02-02 15:46 gagag 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 1.URL中不允许出现空格和双引号,必须使用转义序列替换这些字符。NSString *search = @"Play some \"Abba\"";NSString *escaped = [search stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];//转义后的字符串是“Play%20some%20%22Abba%22”2.NSURLConnection 实例可以通过两种模式与Web服务器通信:同步模式(synchronously)和异步模式(asynchronously) 阅读全文
posted @ 2013-02-01 13:23 gagag 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 1.例子:AddressCard.h接口文件#import<Foundation/Foundation.h>@interface AddressCard:NSObject<NSCoding,NSCoping>@property (copy,nonatomic) NSString *name,email;-(void)setName:(NSString) *theName andEmail:(NSString *)theEmail;-(NSComparisonResult) compareNames:(id)element;-(void)print;AddressCard 阅读全文
posted @ 2013-01-31 16:36 gagag 阅读(3253) 评论(0) 推荐(0) 编辑
摘要: @interface Fraction:NSObject<NSCopying>-(id)copyWithZone:(NSZone*)zone{ Fraction *newFract = [[Fraction allocWithZone:zone]init];//如果Fraction类有子类, //应改为 id newFract = [[self class] allocWithZone:zone] init];// [newFract setTo:numerator over:denominator]; return newFract;} 阅读全文
posted @ 2013-01-31 13:25 gagag 阅读(1353) 评论(0) 推荐(0) 编辑
摘要: 今天读cocoa design patterns 引发的问题 alloc和allocwithzone的存在解决了很多问题,但是还是很疑惑。(随便说句 此书中文版翻译不靠谱。。。)下面是截自http://stackoverflow.com/的一段分析,虽然还没有体会,但是还是保留下来。When one object creates another, it’s sometimes a good idea to make sure they’re both allocated from the same region of memory. The zone method (declared in t 阅读全文
posted @ 2013-01-30 15:28 gagag 阅读(2715) 评论(0) 推荐(0) 编辑
摘要: +(NSFileHandle *)fileHandleForReadingAtPath:path //打开一个文件准备读取+(NSFileHandle *)fileHandleForWritingAtPath:path //打开一个文件准备写入+(NSFileHandle *)fileHandleForUpdatingAtPath:path //打开一个文件准备更新(读取或写入)+(NSData *)availableData //从设备或通道返回可用的数据+(NSData *)readDataToEndOfFile //读取其余的数据直到文件的末尾(最多UINT_MAX字节)-(N... 阅读全文
posted @ 2013-01-29 11:06 gagag 阅读(586) 评论(0) 推荐(0) 编辑
摘要: +(NSProcessInfo*)processInfo //返回当前进程的信息-(NSArray*)arguments //以NSString对象数组的形式返回当前进程的参数-(NSDictionary *)environment //返回变量/值对词典,以描述当前的环境变量(比如PATH和HOME)及其值-(int)processIdentifier //返回进程标识符,它是操作系统赋予进程的唯一数字,用于识别每个正在运行的进程-(NSString*)processName //返回当前正在执行的进程名称-(NSString *)globallyUniqueString //每... 阅读全文
posted @ 2013-01-29 10:33 gagag 阅读(4817) 评论(0) 推荐(0) 编辑
摘要: A: In order to pause animations in a layer tree, you can take advantage of the fact that a CALayer conforms to the CAMediaTiming protocol. The CAMediaTiming protocol defines, among other things, a speed with which its timeline progresses, which you can use to pause all animations on the target layer 阅读全文
posted @ 2013-01-28 17:26 gagag 阅读(295) 评论(0) 推荐(0) 编辑
摘要: 1、常见的NSFileManager文件方法-(NSData *)contentsAtPath:path //从一个文件读取数据-(BOOL)createFileAtPath: path contents:(NSData *)data attributes:attr //向一个文件写入数据-(BOOL)removeItemAtPath:path error:err //删除一个文件-(BOOL)moveItemAtPath:from toPath:to error:err //重命名或者移动一个文件(to不能是已存在的)-(BOOL)copyItemAtPath:from toPath... 阅读全文
posted @ 2013-01-21 21:31 gagag 阅读(23046) 评论(0) 推荐(4) 编辑