Created
January 11, 2018 18:31
-
-
Save fcanas/477567126357d3afb1bace1096f4f64e to your computer and use it in GitHub Desktop.
Copy Properties in Swift
This file contains 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
import Foundation | |
class C { | |
@NSCopying var copiedName: NSString? | |
var noCopyName: NSString? | |
} | |
let f = NSMutableString(string: "First") | |
let obj = C() | |
obj.copiedName = f | |
obj.noCopyName = f | |
obj.copiedName // "First" | |
obj.noCopyName // "First" | |
f.append(" Last") | |
obj.copiedName // "First" | |
obj.noCopyName // "First Last" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment