Simple one: in obj-c, whats the equivalent of C#'s .ToString() method?
Simple one: in obj-c, whats the equivalent of C#'s .ToString() method?
If i have an mystery object of type id, how do i convert it to a string? Is there an e开发者_开发知识库asier way than the below?
NSString *stringVal = [NSString stringWithFormat:@"%@", mysteryIdObject];
[NSObject description]
is probably what you're looking for.
You need to be more specific about what you want. NSObject
has a -description
method, which is intended for use when debugging. Many other classes (like NSNumber
) respond to -stringValue
.
精彩评论