Closed Gerzer closed 3 years ago
@Gerzer actually, would using Swift String be even better than using NSMutableString, multi-platform wise?
Not very sure of Swift things happening outside the Apple ecosystem, hence asking for your opinion on this.
@Gerzer actually, would using Swift String be even better than using NSMutableString, multi-platform wise?
Not very sure of Swift things happening outside the Apple ecosystem, hence asking for your opinion on this.
Yes, String
is much more portable than NSMutableString
. For this pull request, I tried to make the minimum number of changes possible, but in the future, it would be a good idea in general to switch to types from the Swift standard library instead of types from Foundation. Of course, sometimes there won't be any equivalents, but for basic things like strings, the Swift standard library offers sufficient functionality and is (almost) fully portable to Linux and other non-Apple platforms.
@Gerzer Thanks for the info & pull request!
Currently this pull request looks good to me, so I will be merging this pull request, and will eventually try to migrate from NSMutableString
to String
in the future.
The
String(format:_:)
initializer, theNSMutableString()
initializer, andNSMutableString
'sappendFormat(_:)
method are unavailable on Linux, so I replaced them with functionally equivalent alternatives. Additionally, on Linux, the various XML classes in Foundation have been relocated to FoundationXML, so I added a conditional import for it.