11 2011 档案
摘要:Handling unhandled exceptions and signalsWhen an application crashes on the iPhone, it disappears without telling the user what happened. However, it is possible to add exception and signal handling to your applications so that an error message can be displayed to the user or you can save changes. I
阅读全文
摘要://如果想排序以后再取,可以这样:NSSet *users = [groupUser users];NSSortDescriptor *sd = [[NSSortDescriptor alloc] initWithKey:@"displayName" ascending:YES];NSArray *sortDescriptors = [NSArray arrayWithObjects:sd, nil];NSArray *userArray = [users sortedArrayUsingDescriptors:sortDescriptors];//如果直接取,可以这样:N
阅读全文
摘要:内存管理在Objective-C中,NSObject 定义了release和dealloc函数,一般来说,如果你的类中包含有对象,需要重载dealloc函数,在dealloc中释放类成员变量所占用的内存,下面的代码演示了,当给一个对象发送release消息,或者这个对象被自动释放池回收时,dealloc会得到调用,这种行为使用dealloc有点像C++中的析构函数。为什么释放时用release而不是dealloc?原因是需要由release判断引用计数,当引用计数为0时release才会调用dealloc执行实际的释放内存操作。文件 MyClass.h:#import <Foundati
阅读全文
摘要:iOS 4版本加入了无线部署功能,所谓无线部署就是完全脱离iTunes的发布程序的一种方式。“无线部署”的前提是需要收集需要安装该应用程序的设备ID,并使用这些ID创建合适的provisioning profiles 文件。上面的准备工作完成了以后,打开项目,快捷键:Control+Command+O 打开 Organizer, 把对应的provisioning 文件拖动到对应的对话框。菜单栏选择“Build”->“Build and Archive”。选择“Share Application…”;然后,选择“Distribute for Enterprise”.紧接着弹出部署描述...
阅读全文
摘要:在调用视图的drawRect:方法之前,UIKit 会自动对描画环境进行配置,使左上角成为坐标系统的原点,在这个环境中发生的Quartz 调用都可以正确地在视图中描画。视图对象通过frame、bounds、和center 属性声明来跟踪自己的大小和位置。frame 属性包含一个矩形,即边框矩形,用于指定视图相对于其父视图坐标系统的位置和大小。bounds 属性也包含一个矩形,即边界矩形,负责定义视图相对于本地坐标系统的位置和大小。虽然边界矩形的原点通常被设置为(0, 0),但这并不是必须的。center 属性包含边框矩形的中心点。当您在代码中通过initWithFrame:方法创建一个...
阅读全文
摘要:It’s important to optimize any UIView layoutSubviews method you create, as it can be frequently called, and has the potential for creating recursion (triggering a setNeedsLayout from layoutSubviews can create a loop that will grossly affect your apps performance). Layout subviews is called once per
阅读全文
摘要:关于String:1,把一个整数,转换成一个NSString?[NSString stringWithFormat:@"%d",3];2,比较两个NSString是否相等?[@"test" isEqualToString:@"test"];3,@"abcdefg",截取第两个字符开始的三个字符?[@"abcdefg" substringWithRange:NSMakeRange(1, 3)]4,讲解UTF8与Unicode的区别与关系这里有详细讲解5,NSString , NSMutableSt
阅读全文
摘要:viewController 不响应横竖屏转换相关消息的问题罗朝辉(http://blog.csdn.net/kesalin)转载请注明出处有同学在 CocoaChina 上提出这样一个问题:A viewController 中包含一个 B viewController(B 的 view 作为 A 的 view 的 subView),在横竖屏转换时,A 可以得到屏幕旋转相关的消息(如:shouldAutorotateToInterfaceOrientation),而 B 却得不到,即使 A,B 都实现了这些函数。原贴见这里:http://www.cocoachina.com/bbs/read.
阅读全文