i hacking way through swift. love find myself thinking few things may simple , question if it's correct.
i converting project objective-c. in project have string property use in method. in objective-c did following initialize , allocate object. once it's initialized , allocated set empty string.
nsmutablestring *tempstring = [[nsmutablestring alloc] init]; self.currentparsedcharacterdata = tempstring; [currentparsedcharacterdata setstring: @""];
in swift typed following. easy or missing something?
self.currentparsedcharacterdata = ""
i find myself wanting following i'm not sure it's necessary.
var tempstring : string = "" self.currentparsedcharacterdata = tempstring
take care,
jon
yes, easy. in objective-c, have typed self.currentparsedcharacterdata = @"".mutablecopy
, achieved same effect.
@""
in objective-c , ""
in swift object literals allocate memory , initialise you. equally arrays, can @[]
empty nsarray
or []
empty array
(in swift) allocate , initialise empty array.
Comments
Post a Comment