I am still a beginner in IOS programming even I have created some nice Apps for myself.
You can do a lot with copy and paste
Now I have started to learn SWIFT, because I am coming from AppleScript and not from Objective-C.
I want to read the marked text from a text view. Pressing a button should move the selected text to a text field.
log output is :
the Range is startingPoint and Length
Now my question:
I need to have the selected text and not just the position.
There is a class/method with the name = textInRange
In the documentation I see the following description, but I cannot manage to use it.
How do I declare it in swift ? (Creating my own functions are working fine.)
Thank you in advance
pppfff
You can do a lot with copy and paste
Now I have started to learn SWIFT, because I am coming from AppleScript and not from Objective-C.
I want to read the marked text from a text view. Pressing a button should move the selected text to a text field.
Code:
@IBOutlet var myTextField: UITextView
myTextField.text = "big[B] brown fox[/B] jumps over a lamb"
@IBAction func MyButton(sender: AnyObject) {
var textStart = myTextField.selectedTextRange.start
println(textStart)
var textEnd = myTextField.selectedTextRange.end
println(textEnd)
var textRange = myTextField.selectedTextRange
println(textRange)
}
log output is :
Code:
<_UITextKitTextPosition: 0xb2b78e0> (4F)
<_UITextKitTextPosition: 0xb2be7c0> (13B)
<_UITextKitTextRange: 0xb2879e0> (4, 9)B
Now my question:
I need to have the selected text and not just the position.
There is a class/method with the name = textInRange
In the documentation I see the following description, but I cannot manage to use it.
How do I declare it in swift ? (Creating my own functions are working fine.)
Thank you in advance
pppfff
Code:
[I]Return the text in the specified range. (required)
Declaration
SWIFT
func textInRange(_ range: UITextRange!) -> String!
OBJECTIVE-C
- (NSString *)textInRange:(UITextRange *)range [/I]
Last edited by a moderator: