English 中文(简体)
i 希望在纽特点点点点点名的过去的案文中转载选定的案文。 如何做到这一点?
原标题:i want to paste selected text in a text view on button click named paste.how can i do this?
  • 时间:2012-04-24 06:26:15
  •  标签:
  • cocoa

I am new to cocoa prgramming, and I am copying text using the code:

NSRange range = [textView selectedRange];
NSData* rtfData = [textView RTFFromRange: range];
NSAttributedString* aStr = [[NSAttributedString alloc]initWithRTF:rtfData documentAttributes:NULL];
NSString* str = [aStr string];

其中载有选定的案文,但我如何能够在><>/code>>。 我何时在一份案文中点击?

问题回答

页: 1 从自我角度看,你需要执行你希望采取这一行动的代议制。

然后,你可以采用NSText(优等NSTextView)的固定办法确定案文。

Edit-(首先,如果将案文定在案文概览中的话)

NSRange range = [textView selectedRange]; 
NSData* rtfData = [textView RTFFromRange: range];
NSAttributedString* aStr = [[NSAttributedString alloc]initWithRTF:rtfData documentAttributes:NULL];
NSString* str = [aStr string];
[[textView setString:str];

[[textView textStorage] setAttributedString:[[NSAttributedString alloc] initWithString:str]]; 




相关问题
Taking picture with QTCaptureView

Is it possible to simply take a picture and save it somewhere using a QTCaptureView and Apple s built-in iSight? I ve seen lots of tutorials on recording video but none on simply taking a picture. Any ...

Controlling OSX windows

I m trying to control windows of a foreign OSX applications from my application. I d like to 1. move the windows on the screen 2. resize the windows on the screen 3. change the currently active window ...

objective-c: Calling a void function from another controller

i have a void, like -(void) doSomething in a specific controller. i can call it in this controller via [self doSomething], but i don t know how to call this void from another .m file. I want to call ...

NSUndoManager and runModalForWindow:

I have a simple Core Data app which displays a list of entities in the main window. To create or add new entities, I use a second modal window with a separate managed object context so changes can be ...

NSMutableArray values becoming "invalid"

I m trying to show a database information in a tableview and then the detailed information in a view my problem is as follow: I created a NSMutableArray: NSMutableArray *myArray = [[NSMutableArray ...

How to get a flash url in a webpage using a webframe?

As we know , When we load frame from webpage of safari, we will invoke the delegate methods of webkit informal protocol(WebFrameLoadDelegate): webView:didStartProvisionalLoadForFrame: webView:...

热门标签