04 2011 档案

摘要:#如果你想在运行时通过给定的字符串来动态创建对应的对象并且调用某中的方法。#如果你得到一个id对象,但不知道该对象是否含有某方法,如果有就调用它。请看下面的例子:DynObj.h#import <Foundation/Foundation.h>@interface DynObj : NSObject { NSString *name;}@property(nonatomic,retain) NSString* name;- (id) init;- (void) dealloc;-(void) show;@endDynObj.m#import "DynObj.h" 阅读全文
posted @ 2011-04-29 09:43 chenjunbiao 阅读(335) 评论(0) 推荐(0)
摘要:Tester.h#import <Foundation/Foundation.h>@interface Tester : NSObject { }-(void) test:(NSString*) msg;-(void) notImp;@endTester.m#import "Tester.h"@implementation Tester-(void) test:(NSString*) msg{ NSLog(@"%@", msg);}@end注意:没有实现notImp方法main.m#import <Foundation/Foundati 阅读全文
posted @ 2011-04-21 09:50 chenjunbiao 阅读(12137) 评论(2) 推荐(0)
摘要:Tester.h#import <Foundation/Foundation.h>@interface Tester : NSObject { }-(void) Test:(NSString*) msg;@endTester.m#import "Tester.h"@implementation Tester-(void) Test:(NSString*) msg{ NSLog(@"%@", msg); }@endmain.m#import <Foundation/Foundation.h>#import "Tester. 阅读全文
posted @ 2011-04-21 09:37 chenjunbiao 阅读(505) 评论(0) 推荐(0)
摘要:CurrentDate.h#import <Foundation/Foundation.h>@interface CurrentDate : NSObject { }- (NSString *) stringForDate: (NSDate *)date usingFormatter: (NSDateFormatter *)formatter;@endCurrentDate.m#import "CurrentDate.h"@implementation CurrentDate- (NSString *) stringForDate: (NSDate *)date 阅读全文
posted @ 2011-04-20 13:36 chenjunbiao 阅读(2407) 评论(0) 推荐(0)