iphone - 如何从用户定义的对象中提取 NSString?

标签 iphone ios nsstring type-conversion

我有一个对象,假设是类 A,并且其中存储了一个字符串。我想将其类型转换为 NSString 对象。基本上这就是我想要实现的目标:

NSString *temp = (NSString *)[A someMEthod];

if(temp isMemberOfClass : [NSString class]) {
    dosomething
}

有人能告诉我如何实现吗?

最佳答案

id temp = [A someMethod];
if([temp isKindOfClass:[NSString class]])
{
    NSString *str = (NSString *)temp;
    NSLog(@"%@", str);
}

关于iphone - 如何从用户定义的对象中提取 NSString?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10241348/

相关文章:

iphone - 在 iPhone SDK 中使用 CoreData 存储 longLong 值

iphone - 在 iOS WebView 中添加 Facebook 的 Like 按钮

objective-c - 获取多行标签中子字符串中的词框

ios - Xcode 6 没有显示任何模拟器

iphone - 将 NSData 转回纯文本 NSString

ios - 使用黑客永远无法访问的字符串/文本编译/提交 iOS 应用程序

iphone - 增加 tabBarItem 图像大小

iphone - 如何在 UITableViewCell 中获取透明附件 View ? (带屏幕截图)

iphone - uilocalnotification 未在准确时间触发

c# - MonoGame - 在 iOS 上使用 SpriteBatch 平铺 Texture2D