class Program { static void Main(string[] args) { string str= DB.write.ToDescription(); Console.WriteLine(str); Console.ReadKey(); } } public enum DB{ [Description("读")] write=, [Description("写")] read= } public static class MyExceptio…
class Program { static void Main(string[] args) { string str= DB.write.ToDescription(); Console.WriteLine(str); Console.ReadKey(); } } public enum DB{ [Description("读")] write=, [Description("写")] read= } public static class MyExceptio…
知识回顾 在前面已经介绍了如何定义类和创建并初始化对象,比如有Student这个类 1.Student.h 1 #import <Foundation/Foundation.h> 2 3 @interface Student : NSObject { 4 int _age; 5 } 6 - (void)setAge:(int)age; 7 - (int)age; 8 @end 2.Student.m 1 #import "Student.h" 2 3 @implementa…
发布自米高 | Michael - 博客园,源地址:http://www.cnblogs.com/michaellfx/p/4232205.html,转载请注明. 本文结构 基础实现 性能优化 参考 关键字:Objective-C OC description函数 自动打印属性及属性值 运行时枚举成员变量 基础实现 使用NSLog或po,Xcode默认调用对象的description方法,若没实现,则打印对象的地址,不方便查看对象的状态.特别地,在RESTful编程中,服务器返回的JSON对象往…
1.Student.h 1 #import <Foundation/Foundation.h> 2 3 @interface Student : NSObject { 4 int _age; 5 } 6 - (void)setAge:(int)age; 7 - (int)age; 8 @end 2.Student.m 1 #import "Student.h" 2 3 @implementation Student 4 - (void)setAge:(int)age { 5…
知识回顾在第5讲中已经介绍了如何定义类和创建并初始化对象,比如有Student这个类1.Student.h 1 #import <Foundation/Foundation.h>23@interface Student : NSObject {4int _age;5}6 - (void)setAge:(int)age;7 - (int)age;8 @end  2.Student.m  1 #import "Student.h" 2 3@implementation Stud…
[Objective-C]07-自定义构造方法和description方法   // 构造方法:用来初始化对象的方法,是个对象方法,”-"开头// 重写构造方法的目的:为了让对象创建出来,成员变量就会有一些固定的值/* 重写构造方法的注意点1.先调用父类的构造方法([super init])2.再进行子类内部成员变量的初始化 */ // 重写-init方法//- (id)init//{//    // 1.一定要调用回super的init方法:初始化父类中声明的一些成员变量和其他属性//   …
XML文件是一种经常使用的文件格式,比如WinForm里面的app.config以及Web程序中的web.config文件,还有很多重要的场所都有它的身影.Xml是Internet环境中跨平台的,依赖于内容的技术,是当前处理结构化文档信息的有力工具.XML是一种简单的数据存储语言,使用一系列简单的标记描写叙述数据,而这些标记能够用方便的方式建立,尽管XML占用的空间比二进制数据要占用很多其它的空间,但XML极其简单易于掌握和使用.微软也提供了一系列类库来倒帮助我们在应用程序中存储XML文件. "…
一. 分类-Category 1. 基本用途:Category  分类是OC特有的语言,依赖于类. ➢ 如何在不改变原来类模型的前提下,给类扩充一些方法?有2种方式 ● 继承 ● 分类(Category) 2. 格式 ➢ 分类的声明 @interface 类名 (分类名称) // 方法声明 @end ➢ 分类的实现 @implementation 类名 (分类名称) // 方法实现 @end 3. 好处 ➢ 一个庞大的类可以分模块开发 ➢ 一个庞大的类可以由多个人来编写,更有利于团队合作 ➢ …
本文文件夹 知识回想 一.自己定义构造方法 二.description方法 说明:这个Objective-C专题,是学习iOS开发的前奏,也为了让有面向对象语言开发经验的程序猿,可以高速上手Objective-C. 假设你还没有编程经验,或者对Objective-C.iOS开发不感兴趣,请忽略. 学习本专题之前.建议先学习C语言专题. 回到顶部 知识回想 在第5讲中已经介绍了怎样定义类和创建并初始化对象,比方有Student这个类 1.Student.h 1 #import <Foundatio…