开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜