>
> Note that there is a distinction between "print an object" and "perform
> string interpolation on an object and print that string".
>
>print(c)// I have the lot
>print("\(c)") // I have the lot
>debugPrint(c) // I am CustomDebugStringConvertible
>debu
> On Jul 11, 2015, at 6:29 PM, Roland King wrote:
>
>>
>> However, Roland got it slightly wrong, according to the documentation. This:
>>
>> print (“\(myObj)”)
>>
>> never uses debugDescription, only description. To use debugDescription (if
>> it exists, or description instead):
>>
>>
>
> However, Roland got it slightly wrong, according to the documentation. This:
>
> print (“\(myObj)”)
>
> never uses debugDescription, only description. To use debugDescription (if it
> exists, or description instead):
>
> debugPrint (“\(myObj)”)
Dunno about the documentation -
On Jul 11, 2015, at 11:51 , Jens Alfke wrote:
>
> I think William asked how to implement a custom description, not how to print
> it.
Roland was pointing out that Swift uses the custom description for string
interpolation, which is the equivalent of using a “%@“ format string in Obj-C.
That d
I think William asked how to implement a custom description, not how to print
it.
The method is the same (for compatibility): description(). But since Swift is
stricter about typing, you have to implement the Printing (sp?) protocol, which
contains just that one method, to signal that your clas
> On 11 Jul 2015, at 22:24, William Squires wrote:
>
> In ObjC, I can have a class implement the description message so I can do:
>
> MyClass *myObj = [[MyClass alloc] init];
>
> NSLog("%@", myObj);
>
> and it will be as if I did:
>
> NSString *aDesc = [myObj description];
> NSLog("%@", aDes
In ObjC, I can have a class implement the description message so I can do:
MyClass *myObj = [[MyClass alloc] init];
NSLog("%@", myObj);
and it will be as if I did:
NSString *aDesc = [myObj description];
NSLog("%@", aDesc);
What's the Swift equivalent?
_