随笔分类 -  iphone跬步

不积跬步,无以至千里
摘要:获取每段子字符串数组,字符串被指定的字符分割(比如"\r\n")NSArray *arr = [testStr componentsSeparatedByString:@"\r\n"];字符串替换NSString *str =[testStr stringByReplacingOccurrencesOfString:@"\\n" withString:@"\r\n"];获取字符串@"testKey=testValue"中的key和valueNSString *testStr = @"t 阅读全文
posted @ 2012-07-12 16:27 月光的尽头 阅读(577) 评论(0) 推荐(0) 编辑
摘要:一、获取系统的错误信息比如移动文件时,获取文件操作错误:NSError *e = nil;[[NSFileManager defaultManager] moveItemAtPath:sourcePath toPath:targetPath error:&e];if (e) { NSLog(@"move failed:%@", [e localizedDescription]);}先定一个空的错误信息NSError *e = nil;取地址&e 如果有错误信息,打印错误的本地化描述if (e) { NSLog(@"move failed:%@&qu 阅读全文
posted @ 2012-07-04 15:21 月光的尽头 阅读(54389) 评论(2) 推荐(2) 编辑
摘要:1.获取app的info.plist详细信息版本号:Bundle version NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];应用标识:Bundle identifierNSString *bundleId = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];应用名称:Bundle display nameNSS 阅读全文
posted @ 2012-07-03 14:34 月光的尽头 阅读(9007) 评论(0) 推荐(2) 编辑
摘要:一、加载xib文件用例:在类TestOjbect中加载test.xib文件[[NSBundle mainBundle] loadNibNamed:@"test"owner:selfoptions:nil];当owner是self时,test.xib的基类必须继承自TestOjbect(owner是什么对象,则test.xib必须继承该对象,或该对象的子类)上面的方法返回xib中对外公开的对象的数组(NSArray)二、加载其他文件用例:加载app包中的content.plist文件NSString *path = [[NSBundle mainBundle] pathFor 阅读全文
posted @ 2012-04-16 22:57 月光的尽头 编辑
摘要:1.NSNotification:消息或通知有三个成员变量- (NSString *)name;- (id)object;- (NSDictionary *)userInfo;通知名称:name,消息发送者:object,代理在收到NSNotification方法里,可以回调到object附加信息:userInfo2.NSNotificationCenter:消息中心单例模式,需要通过以下类方法访问[NSNotificationCenter defaultCenter]3.广播一个通知[[NSNotificationCenter defaultCenter] postNotificationN 阅读全文
posted @ 2012-03-26 14:06 月光的尽头 编辑
摘要:1.声明一个定时器变量NSTimer *_timer;2.启动一个定时器- (void)startTimer{ _timer = [[NSTimer scheduledTimerWithTimeInterval:30 target:self selector:@selector(onTimer) userInfo:nil repeats:NO] retain];}定时时间30秒,30秒后调用self的onTimer方法,执行定时操作,不重复3.停止或中断定时器- (void)stopTimer{ if(_timer != nil){ [_timer invalidat... 阅读全文
posted @ 2012-03-26 13:14 月光的尽头 编辑