代码改变世界

转自国外的一篇博文,对Assign, retain ,copy的解释,非常值得一看

2012-03-26 14:20 by 白山, 325 阅读, 0 推荐, 收藏, 编辑
摘要:Assign, retain, copy: pitfalls in Obj-C property accessorsIn this post, I'll look at some very subtle problems that can occur if a getter or setter method chooses the wrong memory management pattern and in the process, explain why NSDictionary copies its keys rather than simply retains them.Scop 阅读全文

转-UITabBar各部分自定义设置

2012-03-07 12:45 by 白山, 650 阅读, 0 推荐, 收藏, 编辑
摘要:一、自定义TabBar选项卡背景UITabBarController *tabBarController = [[UITabBarController alloc] init];// 获取选项卡控制器视图的所有子视图,保存到一数组中NSArray *array = [tabBarController.view subviews];// 索引值为1的应该就是TabBarUITabBar *tabBar = [array objectAtIndex:1];// UIImage *image = [UIImage imageNamed:@"tabbarbg.png"];UIIma 阅读全文

判断设备是否越狱

2012-03-06 11:59 by 白山, 638 阅读, 0 推荐, 收藏, 编辑
摘要:1 #import <Foundation/Foundation.h> 2 #import <mach-o/dyld.h> 3 #import <sys/sysctl.h> 4 5 #define FAT_CIGAM 0xbebafeca 6 7 #define ARMV6 6 8 #define ARMV7 9 9 10 #define LC_CODE_SIGNATURE 0x1d11 #define LC_ENCRYPTION_INFO 0x2112 13 #define LC_SEGMENT 0x114 15 struct fat_arch {16 u 阅读全文

CoreText库中使用CTFramesetter,根据文本内容实现丰富的Frame

2012-03-05 14:45 by 白山, 3339 阅读, 0 推荐, 收藏, 编辑
摘要://textContent:要在Frame中填充的文本内容CFMutableAttributedStringRef attributeRef = CFAttributedStringCreateMutable(kCFAllocatorDefault, 0);CFAttributedStringReplaceString(attributeRef, CFRangeMake(0, 0), (CFStringRef)textContent);//设定文本格式CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();CGFloat compo 阅读全文

NSUserDefaults 存储用户设定

2012-02-23 12:46 by 白山, 158 阅读, 0 推荐, 收藏, 编辑
摘要:NSUserDefaults 可用来存储一些用户的设定,存储类型一般为小型的数据结构 例: [[NSUserDefaults standardUserDefaults] setInteger:value forKey:value]; [[NSUserDefaults standardUserDefaults] synchronize]; synchronize方法同步存储到本地磁盘 获取数据: [[NSUserDefaults standardUserDefaults] stringForKey:[self getAttributeKey:key]]; 阅读全文