Swift String initializers? -


i came across these 2 statements in swift teaching book.

  1. let padding = string(count: spaces, repeatedvalue: character(" "))
  2. println(string(format:"%@%@", "year", "test"))

my questions are:

  1. are both string(count:repeatedvalue:) , string(format:) initializers of
    string?
  2. i not able find online documentation string(format:) can please suggest links?
  3. 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 /// ================== /// /// string bridged objective-c nsstring, , string /// originated in objective-c may store characters in /// nsstring. since arbitrary subclass of nssstring can /// become string, there no guarantees representation or /// efficiency in case. since nsstring immutable, /// though storage shared copy: first in /// sequence of mutating operations causes elements copied /// unique, contiguous storage may cost o(n) time , /// space, n length of string representation (or /// more, if underlying nsstring has 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

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -