错误原因:
exc_bad_access(code=1, address=0x789870)野指针错误,主要的原因是,当某个对象被完全释放,也就是retainCount,引用计数为0后。再去通过该对象去调用其它的方法就会出现野指针错误。
例如:
Person *jerry = [[Person alloc]init]; // retainCount引用计数为1
[jerry eat];...
分类:
移动开发 时间:
2014-07-22 23:05:16
阅读次数:
372
系统字体NSArray *familyNames = [[NSArray alloc]
initWithArray:[UIFont familyNames]];NSArray *fontNames;NSInteger indFamily,
indFont;for (indFamily=0; indF...
分类:
移动开发 时间:
2014-05-01 09:25:36
阅读次数:
572
#import
"loveView.h"//点击按钮-(void)buttonclick{UIWindow *window = [UIApplication
sharedApplication].keyWindow;loveView *loveview = [[loveView alloc] ini...
分类:
其他好文 时间:
2014-05-01 08:14:54
阅读次数:
310
//导航栏按钮 UIBarButtonItem *doneButton =
[[UIBarButtonItem alloc] initWithTitle:@"完成" ...
分类:
其他好文 时间:
2014-05-01 06:07:20
阅读次数:
224
dispatch_once的实现分析
dispatch_once可以保证代码被执行一次
+(NSDateFormatter*)getDBDateFormat
{
static NSDateFormatter* format;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
format = [[LKDateFormatter alloc]init];
format.dateF...
分类:
其他好文 时间:
2014-04-30 22:12:40
阅读次数:
336
1、指针和对象,都是内存块。一个大,一个小。一个在栈中,一个在堆中。2、iOS中,我们可以生命一个指针,也可以通过alloc获取一块内存。3、我们可以直接消灭掉一个指针,将其置为nil。但是我们没办法直接消灭一块对象内存。对于对象内存,我们永远只能依靠系统去回收。而什么时候回收,就需要使用苹果为我们...
分类:
移动开发 时间:
2014-04-30 15:43:38
阅读次数:
606
NSPredicate:对self每个对象通过谓词进行筛选,判断是否与条件相匹配。原理和用法都类似于SQL查询中的where,作用相当于数据库的过滤取。主要用于从集合中分拣出符合条件的对象,也可以用于字符串的正则匹配
第一、contains 判断
NSArray *array = [[NSArray
alloc]initWithObjects:@"beijing",@"s...
分类:
其他好文 时间:
2014-04-29 13:32:23
阅读次数:
375
1.有缓存:读取后放入缓存中下次可直接读取,适用于图片较少且频繁使用。[UIImage
imageNamed:@"文件名"];2.无缓存:用完就释放掉,参数传的是全路径,适用于图片较多的情况下。[UIImage alloc]
initWithContentsOfFile:@"文件全路径"];
分类:
其他好文 时间:
2014-04-29 10:41:47
阅读次数:
275
我们一般切换UIViewController的时候用的是如下代码
#import "UIViewControllerDemo.h"
UIViewControllerDemo *vc = [UIViewControllerDemo alloc] initWithNibName:nil bundle:nil] autorelease];
[self.navigationController pushViewController:vc animated:YES];...
分类:
其他好文 时间:
2014-04-27 21:21:00
阅读次数:
294