第21章 Pasteboards and Nil-Targeted Actions
来源:互联网 发布:剧情av知乎 编辑:程序博客网 时间:2024/05/24 02:11
pasteboard是一个运行在MAC上的服务程序。在应用程序中,可以通过NSPasteboard类将数据写入这个程序中,也可以从
它里面读取出来。这样就可以完成 copy,paste,cut等功能。
使用NSpasteboard的步骤可以用以下代码来说明:
- (void)writeToPasteboard: (NSPasteboard *)pb
{
// Declare types
[pb declareTypes:[NSArray arrayWithObject:NSStringPboardType]
owner:self];
// Copy data to the pasteboard
[pb setString:string forType:NSStringPboardType];
}
- (BOOL)readFromPasteboard: (NSPasteboard *)pb
{
// Is there a string on the pasteboard?
NSArray *types = [pb types];
if ([types containsObject:NSStringPboardType]) {
// Read the string from the pasteboard
NSString *value = [pb stringForType:NSStringPboardType];
// Our view can handle only one letter
if ([value length] == 1) {
[self setString:value];
return YES;
}
}
return NO;
}
在应用程序中可能包含多个view,那么哪个view来接收copy,paste等消息呢?nil-target就是为了解决这个问题产生的
。使用nil-target可以使得消息以一定的顺序在类之间查找,直到找到符合条件的view来相应消息。
- 第21章 Pasteboards and Nil-Targeted Actions
- A nil-targeted action
- iOS - Actions and Outlet
- 7.【cocos2d翻译系列】Actions, Transformations and Effects--Composition actions
- 8.【cocos2d翻译系列】Actions, Transformations and Effects--Ease actions
- 9.【cocos2d翻译系列】Actions, Transformations and Effects--Effect actions
- 10.【cocos2d翻译系列】Actions, Transformations and Effects--Special actions
- Change request, Corrective Actions, and Preventive actions, Defect Repair
- Actions and Attributes from Wholes and Parts
- actions
- Actions
- Actions
- Actions
- Actions
- Actions
- Silverlight 触发器与动作(Triggers and Actions)
- Silverlight 触发器与动作(Triggers and Actions)
- Silverlight 触发器与动作(Triggers and Actions)
- 经典编程书籍(C++, 网络, Windows, Linux)
- Spring3中@Autowired注入的顺序
- 制作blog遇到的问题
- 第18章 Images and Mouse Events
- 第19~20章 Keyboard Events & Drawing Text with Attributes
- 第21章 Pasteboards and Nil-Targeted Actions
- 【算法学习】堆排序(Heap Sorting)
- 第22章 Categories
- 第24章 NSTimer
- 【iOS-cocos2d-X 游戏开发之十三】详细讲解在Xcode中利用预编译并通过Jni调用Android的Java层代码(cocos2dx里访问调用Android函数)!
- 第26章 Creating NSFormatters
- python 得到文件版本信息 公司名和产品名(2)
- 第29章 View Swapping
- 类成员与多对象、多线程、多继承