开发者

Simple one: in obj-c, whats the equivalent of C#'s .ToString() method?

开发者 https://www.devze.com 2023-02-24 00:21 出处:网络
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

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

精彩评论

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