Fixed infinite recursion during initialization.
This commit is contained in:
@@ -49,6 +49,8 @@ public enum MTTextAlignment : UInt {
|
|||||||
@IBDesignable
|
@IBDesignable
|
||||||
public class MTMathUILabel : MTView {
|
public class MTMathUILabel : MTView {
|
||||||
|
|
||||||
|
private var _mathList:MTMathList?
|
||||||
|
|
||||||
/** The `MTMathList` to render. Setting this will remove any
|
/** The `MTMathList` to render. Setting this will remove any
|
||||||
`latex` that has already been set. If `latex` has been set, this will
|
`latex` that has already been set. If `latex` has been set, this will
|
||||||
return the parsed `MTMathList` if the `latex` parses successfully. Use this
|
return the parsed `MTMathList` if the `latex` parses successfully. Use this
|
||||||
@@ -56,27 +58,31 @@ public class MTMathUILabel : MTView {
|
|||||||
is preferred to use `latex`.
|
is preferred to use `latex`.
|
||||||
*/
|
*/
|
||||||
var mathList:MTMathList? {
|
var mathList:MTMathList? {
|
||||||
didSet {
|
set {
|
||||||
mathList = nil
|
_mathList = newValue
|
||||||
error = nil
|
error = nil
|
||||||
latex = MTMathListBuilder.mathListToString(mathList)
|
_latex = MTMathListBuilder.mathListToString(mathList)
|
||||||
self.invalidateIntrinsicContentSize()
|
self.invalidateIntrinsicContentSize()
|
||||||
self.setNeedsLayout()
|
self.setNeedsLayout()
|
||||||
}
|
}
|
||||||
|
get { _mathList }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var _latex:String=""
|
||||||
|
|
||||||
/** The latex string to be displayed. Setting this will remove any `mathList` that
|
/** The latex string to be displayed. Setting this will remove any `mathList` that
|
||||||
has been set. If latex has not been set, this will return the latex output for the
|
has been set. If latex has not been set, this will return the latex output for the
|
||||||
`mathList` that is set.
|
`mathList` that is set.
|
||||||
@see error */
|
@see error */
|
||||||
@IBInspectable
|
@IBInspectable
|
||||||
public var latex = "" {
|
public var latex:String {
|
||||||
didSet {
|
set {
|
||||||
|
_latex = newValue
|
||||||
self.error = nil
|
self.error = nil
|
||||||
var error : NSError? = nil
|
var error : NSError? = nil
|
||||||
mathList = MTMathListBuilder.build(fromString: latex, error: &error)
|
_mathList = MTMathListBuilder.build(fromString: latex, error: &error)
|
||||||
if error != nil {
|
if error != nil {
|
||||||
self.mathList = nil
|
_mathList = nil
|
||||||
self.error = error
|
self.error = error
|
||||||
self.errorLabel?.text = error!.localizedDescription
|
self.errorLabel?.text = error!.localizedDescription
|
||||||
self.errorLabel?.frame = self.bounds
|
self.errorLabel?.frame = self.bounds
|
||||||
@@ -87,6 +93,7 @@ public class MTMathUILabel : MTView {
|
|||||||
self.invalidateIntrinsicContentSize()
|
self.invalidateIntrinsicContentSize()
|
||||||
self.setNeedsLayout()
|
self.setNeedsLayout()
|
||||||
}
|
}
|
||||||
|
get { _latex }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This contains any error that occurred when parsing the latex. */
|
/** This contains any error that occurred when parsing the latex. */
|
||||||
|
|||||||
Reference in New Issue
Block a user