摘要: /* libxml/tree.h file not found 设置libxml2文件路径 并添加 libxml.2.2.dylib库文件; 1:Project-->Build Settings --> Header Search Paths --->添加 /usr/include/libxml2 2:Project ---> Build Phases ---> Link Binary With Libraries ---> 添加 libxml.2.2.dylib 库文件 ; */ 阅读全文
posted @ 2013-05-16 21:51 cocoajin 阅读(442) 评论(0) 推荐(0) 编辑
摘要: #import <Foundation/Foundation.h> #import "JSONKit.h" int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSString *res = nil; /* * json格式编码 */ //字符串 NSString *str = @"this is a nsstring"; r... 阅读全文
posted @ 2013-05-16 21:49 cocoajin 阅读(226) 评论(0) 推荐(0) 编辑
摘要: 1:JSON转XML---通常把JSON数据写到Plist文件即可;2:XML数据转JSON-- 使用开源类 XMLReader 先XML数据先转换为 NSDictionary 即可3: 开源类XMLReader 1 // 2 // XMLReader.h 3 // 4 // 5 /* 6 本类使用方法: 7 1:在使用的页面里面 导入本类 #import "XMLReader.h" 8 2: 调用XMLReader 的两个类方法 就可以了,就可以返回字典数据; 9 3:得到 NSDictionary数据,就是JSON 数据了;10 ... 阅读全文
posted @ 2013-05-16 20:19 cocoajin 阅读(679) 评论(0) 推荐(0) 编辑
摘要: 1.实例变量命名规范:_name下划线起始。国内编程无此习惯,要知道下划线起始的是实例变量2.protected继承类的时候可以用,即子类可用其父类的protected型实例变量3.getter方法名称不能是 -(int)getAge这样,应写为-(int)age;4.带形参的函数中“:”是函数名的一部分5.设置器、访问器,即getter、setter方法6.只读,就是没有setter方法,实例变量可以在getter方法中返回一个默认值,如果用@property属性,则自定义一个getter方法,且最好不要与默认getter方法名重名,例如:@property(retain,nonatomic 阅读全文
posted @ 2013-05-16 14:12 cocoajin 阅读(179) 评论(0) 推荐(0) 编辑
摘要: @property和@synthesize总是配对使用的,功能是让编译器自动生成一个与数据成员相关的读写方法,类似与Java的setter/getter方法。@property的参数有三种类型:读写属性: (readwrite/readonly)setter语意:(assign/retain/copy)原子性: (atomicity/nonatomic)读写属性即设置数据成员是可写还是只读,默认是readwrite,如果是readonly则相当于不生成setter方法。原子性即设置数据成员是否可以多线程访问,默认nonatomic,这样性能更好。关于setter语意,举个例子:NSString 阅读全文
posted @ 2013-05-16 13:55 cocoajin 阅读(275) 评论(0) 推荐(0) 编辑
摘要: IOS self.使用 个人习惯;只需要在属性初始化的时候使用self.属性,其他时候直接使用属性名就行;使用self.是 使retaincount+1,为了确保当前类对此属性具有拥有权@interface CustomClass : UIViewController{ NSString *str}@property (retain, nonatomic) NSString *str;@implementation CustomClass@synthesize str;-(void)viewDidLoad{ //方法一 用alloc必须手动释放一次 self.str = ... 阅读全文
posted @ 2013-05-16 13:54 cocoajin 阅读(245) 评论(0) 推荐(0) 编辑
摘要: /* assign retain copy的setter方法的内部实现 assign: //@property float price; - (void)setPrice:(float)price { _price = price; } - (float)price { return _price; } retain: //@property (retain, readwrite, nonatomic) NSStri... 阅读全文
posted @ 2013-05-16 13:48 cocoajin 阅读(553) 评论(0) 推荐(0) 编辑
摘要: Student.h 1 #import <Foundation/Foundation.h> 2 3 @interface Student : NSObject 4 { 5 // 实例变量命名 以 _开头,和系统命名规范一致; 6 7 //1:public的实例变量可以用 -> 方式访问; 8 @public 9 NSString *_publicName;10 //2:默认为protected 权限;子类可以继承;11 @protected12 NSString *_protectedName;13 14 //4:@prope... 阅读全文
posted @ 2013-05-16 13:45 cocoajin 阅读(426) 评论(0) 推荐(0) 编辑