云服务器哪家好
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
工具
TVP
最新优惠活动
文章/答案/技术大牛
搜索
搜索
关闭
发布
精选内容/技术社群/优惠产品,
尽在小程序
立即前往
首页
标签
dynamic
#
dynamic
关注
专栏文章
(144)
技术视频
(0)
互动问答
(3)
PopupMenu的后处理怎么做?
0
回答
dynamic
、
row
、
sequence
、
wolfram-mathematica
、
函数
@synthesize vs @dynamic,有什么区别?
2
回答
dynamic
天使的炫翼
可以看下这个实例 #import <Foundation/Foundation.h> @interface Book : NSObject { NSMutableDictionary *data; } @property (retain) NSString *title; @property (retain) NSString *author; @end @implementation Book @dynamic title, author; - (id)init { if ((self = [super init])) { data = [[NSMutableDictionary alloc] init]; [data setObject:@"Tom Sawyer" forKey:@"title"]; [data setObject:@"Mark Twain" forKey:@"author"]; } return self; } - (void)dealloc { [data release]; [super dealloc]; } - (NSMethodSignature *)methodSignatureForSelector:(SEL)selecto { NSString *sel = NSStringFromSelector(selector); if ([sel rangeOfString:@"set"].location == 0) { return [NSMethodSignature signatureWithObjCTypes:"v@:@"]; } else { return [NSMethodSignature signatureWithObjCTypes:"@@:"]; } } - (void)forwardInvocation:(NSInvocation *)invocation { NSString *key = NSStringFromSelector([invocation selector]); if ([key rangeOfString:@"set"].location == 0) { key = [[key substringWithRange:NSMakeRange(3, [key length]-4)] lowercaseString]; NSString *obj; [invocation getArgument:&obj atIndex:2]; [data setObject:obj forKey:key]; } else { NSString *obj = [data objectForKey:key]; [invocation setReturnValue:&obj]; } } @end int main(int argc, char **argv) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; Book *book = [[Book alloc] init]; printf("%s is written by %s\n", [book.title UTF8String], [book.author UTF8String]); book.title = @"1984"; book.author = @"George Orwell"; printf("%s is written by %s\n", [book.title UTF8String], [book.author UTF8String]); [book release]; [pool release]; return 0; }...
展开详请
赞
0
收藏
0
评论
0
分享
可以看下这个实例 #import <Foundation/Foundation.h> @interface Book : NSObject { NSMutableDictionary *data; } @property (retain) NSString *title; @property (retain) NSString *author; @end @implementation Book @dynamic title, author; - (id)init { if ((self = [super init])) { data = [[NSMutableDictionary alloc] init]; [data setObject:@"Tom Sawyer" forKey:@"title"]; [data setObject:@"Mark Twain" forKey:@"author"]; } return self; } - (void)dealloc { [data release]; [super dealloc]; } - (NSMethodSignature *)methodSignatureForSelector:(SEL)selecto { NSString *sel = NSStringFromSelector(selector); if ([sel rangeOfString:@"set"].location == 0) { return [NSMethodSignature signatureWithObjCTypes:"v@:@"]; } else { return [NSMethodSignature signatureWithObjCTypes:"@@:"]; } } - (void)forwardInvocation:(NSInvocation *)invocation { NSString *key = NSStringFromSelector([invocation selector]); if ([key rangeOfString:@"set"].location == 0) { key = [[key substringWithRange:NSMakeRange(3, [key length]-4)] lowercaseString]; NSString *obj; [invocation getArgument:&obj atIndex:2]; [data setObject:obj forKey:key]; } else { NSString *obj = [data objectForKey:key]; [invocation setReturnValue:&obj]; } } @end int main(int argc, char **argv) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; Book *book = [[Book alloc] init]; printf("%s is written by %s\n", [book.title UTF8String], [book.author UTF8String]); book.title = @"1984"; book.author = @"George Orwell"; printf("%s is written by %s\n", [book.title UTF8String], [book.author UTF8String]); [book release]; [pool release]; return 0; }
相关
产品
热门
专栏
有三AI
417 文章
80 订阅
Mac资源分享
162 文章
22 订阅
DotNet NB && CloudNative
747 文章
51 订阅
Mac应用教程
316 文章
25 订阅
CNNer
385 文章
45 订阅
领券
http://www.vxiaotou.com