摘要: Objective-C的集合类序列化到文件中或者从文件中反序列化其实很简单,请看下面的示例代码:NSArray*array =[NSArrayarrayWithObjects: @"Hefeweizen", @"IPA", @"Pilsner", @"Stout",nil];NSDictionary*dictionary =[NSDictionarydictionaryWithObjectsAndKeys: array, @"array", @"Stout", @" 阅读全文
posted @ 2012-07-05 17:39 Leon Chen2012 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 效果图:iphone sdk已经给我们实现好了NSXMLParser,我们只需继承重写一些方法既可。代码声明:#import<Foundation/Foundation.h>@interfaceXmlWelcome :NSXMLParser{NSMutableArray*ones;NSMutableDictionary*one;intinOne;intinTwo;intTag;}@property(nonatomic,retain) NSMutableArray *ones;@end声明实现:#import“XmlWelcome.h”@implementationXmlWelcom 阅读全文
posted @ 2012-07-05 17:35 Leon Chen2012 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 下面是一个最简单的例子。效果如图:上面用到了json传递的数据,有关json部分,iphone sdk虽然没有支持,但是第三方已经写好了。json 参考:http://code.google.com/p/json-framework/下面是具体的代码实现:数据加载:#import“MyDataSource.h”#import“JSON.h”@implementationMyDataSource+ (NSDictionary*)fetchLibraryInformation{NSString*urlString = [NSStringstringWithFormat:@"http:// 阅读全文
posted @ 2012-07-05 12:15 Leon Chen2012 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 实现一个显示文字为测试的视图,然后经过3秒钟测试文字变为回调函数文字。相应的截图如下:实现的代码如下:定义协议:#import <UIKit/UIKit.h>@protocol NoteDelegate//回调函数-(void)messageCallBack:(NSString *)string;@end调用协议:#import <Foundation/Foundation.h>#import "NoteDelegate.h"@interface ManagerMessage : NSObject { id<NoteDelegate> * 阅读全文
posted @ 2012-07-05 11:24 Leon Chen2012 阅读(162) 评论(0) 推荐(0) 编辑
摘要: http://www.cnblogs.com/yeti/archive/2010/05/14/1735592.htmlScenario: 希望在app退出时保存当前View中的UITextView的值,以便在app重新打开时显示用户退出前编辑的内容。 在AppDelegate的applicationWillTerminate中已经包含了保存NSUserDefaults的代码,仅需View在app退出时将UITextView的值保存在NSUserDefaults中。 首先考虑的是在ViewController中通过接收处理系统的UIApplicationWillTerminateNotifica 阅读全文
posted @ 2012-07-05 11:12 Leon Chen2012 阅读(263) 评论(0) 推荐(0) 编辑