Swift String initializers? -
i came across these 2 statements in swift teaching book.
let padding = string(count: spaces, repeatedvalue: character(" "))println(string(format:"%@%@", "year", "test"))
my questions are:
- are both
string(count:repeatedvalue:),string(format:)initializers of
string? - i not able find online documentation
string(format:)can please suggest links? - what other initializers of string available? can find
init(),init(count:repeatedvalue)in apple documentation
thank much.
string structure in swift. can documentation in xcode itself.
here below details.
/// objective-c bridge /// ================== /// ///
stringbridged objective-cnsstring, ,string/// originated in objective-c may store characters in ///nsstring. since arbitrary subclass ofnssstringcan /// becomestring, there no guarantees representation or /// efficiency in case. sincensstringimmutable, /// though storage shared copy: first in /// sequence of mutating operations causes elements copied /// unique, contiguous storage may costo(n)time , /// space,nlength of string representation (or /// more, if underlyingnsstringhas unusual performance /// characteristics).
struct string { init() } here extension string.
extension string { /// construct instance concatenation of `sz` copies /// of `repeatedvalue` init(count sz: int, repeatedvalue c: character) /// construct instance concatenation of `sz` copies /// of `character(repeatedvalue)` init(count: int, repeatedvalue c: unicodescalar) /// `true` iff `self` contains no characters. var isempty: bool { } }
Comments
Post a Comment