Commit a86fc878 by Daniel Dahan

development: updated Text interface

parent a3638453
......@@ -20,8 +20,8 @@ import UIKit
@objc(TextDelegate)
public protocol TextDelegate {
optional func textStorageWillProcessEdit(text: Text!, textStorage: TextStorage!, string: String!, range: NSRange)
optional func textStorageDidProcessEdit(text: Text!, textStorage: TextStorage!, string: String!, result: NSTextCheckingResult!, flags: NSMatchingFlags, stop: UnsafeMutablePointer<ObjCBool>)
optional func textStorageWillProcessEdit(text: Text, textStorage: TextStorage, string: String, range: NSRange)
optional func textStorageDidProcessEdit(text: Text, textStorage: TextStorage, string: String, result: NSTextCheckingResult, flags: NSMatchingFlags, stop: UnsafeMutablePointer<ObjCBool>)
}
public class Text: NSObject {
......@@ -49,14 +49,17 @@ public class Text: NSObject {
*/
public weak var delegate: TextDelegate?
/**
:name: init
*/
override public init() {
textStorage = TextStorage()
super.init()
textStorage.searchExpression = NSRegularExpression(pattern: searchPattern, options: nil, error: nil)
textStorage.textStorageWillProcessEdit = { (textStorage: TextStorage!, string: String!, range: NSRange) -> Void in
textStorage.textStorageWillProcessEdit = { (textStorage: TextStorage, string: String, range: NSRange) -> Void in
self.delegate?.textStorageWillProcessEdit?(self, textStorage: textStorage, string: string, range: range)
}
textStorage.textStorageDidProcessEdit = { (textStorage: TextStorage!, result: NSTextCheckingResult!, flags: NSMatchingFlags, stop: UnsafeMutablePointer<ObjCBool>) -> Void in
textStorage.textStorageDidProcessEdit = { (textStorage: TextStorage, result: NSTextCheckingResult, flags: NSMatchingFlags, stop: UnsafeMutablePointer<ObjCBool>) -> Void in
self.delegate?.textStorageDidProcessEdit?(self, textStorage: textStorage, string: textStorage.string, result: result, flags: flags, stop: stop)
}
}
......
......@@ -18,8 +18,8 @@
import UIKit
internal typealias TextStorageWillProcessEdit = (TextStorage!, String!, NSRange) -> Void
internal typealias TextStorageDidProcessEdit = (TextStorage!, NSTextCheckingResult!, NSMatchingFlags, UnsafeMutablePointer<ObjCBool>) -> Void
internal typealias TextStorageWillProcessEdit = (TextStorage, String, NSRange) -> Void
internal typealias TextStorageDidProcessEdit = (TextStorage, NSTextCheckingResult, NSMatchingFlags, UnsafeMutablePointer<ObjCBool>) -> Void
public class TextStorage: NSTextStorage {
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment