ios - Is there any dump() like function returns a string? -


i swift's dump() function this,

class myclass {     let = "hello"     let b = "bye!"     init() {} } let myclass = myclass()  dump(myclass) // printed out these lines xcode's console /*  ▿ myclass #0  - a: hello  - b: bye!  */ 

but dump() doesn't return string. prints out console, , returns 1st parameter itself.

 public func dump<t>(x: t, name: string? = default, indent: int = default, maxdepth: int = default, maxitems: int = default) -> t 

is there dump() function returns string?

from: https://github.com/apple/swift/blob/master/stdlib/public/core/outputstream.swift

/// can send output of standard library's `print(_:to:)` , /// `dump(_:to:)` functions instance of type conforms /// `textoutputstream` protocol instead of standard output. swift's /// `string` type conforms `textoutputstream` already, can capture /// output `print(_:to:)` , `dump(_:to:)` in string instead of /// logging standard output. 

example:

let myclass = myclass() var myclassdumped = string() dump(myclass, to: &myclassdumped) // myclassdumped contains desired content. nothing printed stdout. 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo