Last active
September 2, 2016 13:07
-
-
Save odrobnik/417af9fbd8c54d3f722f9dd29841f34a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// The current element attributes state | |
internal struct TagAttributes | |
{ | |
var tagName: String! | |
var URL: NSURL? | |
var imageURL: NSURL? | |
var isUnderlined: Bool = false | |
var isStriken: Bool = false | |
var color: UIColor? | |
var fontAttributes: TagFontAttributes! | |
var textAlignment: NSTextAlignment = .Natural | |
} | |
/// A stack of the element attributes | |
internal var tagAttributesStack = [TagAttributes]() | |
if var tagAttributes = self.tagAttributesStack.last, let tagName = tagAttributes.tagName where tagName == "img" | |
{ | |
tagAttributes.imageURL = NSURL(string: string) | |
// replace the value type with the modified version | |
self.tagAttributesStack[self.tagAttributesStack.count-1] = tagAttributes | |
} |
Wouldn't something like this work?
if let tagAttributes = self.tagAttributesStack.last, let tagName = tagAttributes.tagName where tagName == "img"
{
self.tagAttributesStack.last?.imageURL = NSURL(string: string)
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can have the changed variable inside a box class and it will work: