ksnowlv

回顾过去,总结以往;立足现在,铭记当下;技术为主,笔记而已.

iPhone判断一个类是否存在

| Comments

如何在判断一个类是否在当前SDK版本中是否存在?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Class JSONSerialization = NSClassFromString(@"NSJSONSerialization");

if (JSONSerialization) {
    NSLog(@"NSJSONSerialization exist!");
}
else
{
    NSLog(@"NSJSONSerialization not exist!");
}

JSONSerialization = NSClassFromString(@"JSONSerialization");

if (JSONSerialization) {
    NSLog(@"JSONSerialization exist!");
}
else
{
    NSLog(@"JSONSerialization not exist!");
}

Comments

comments powered by Disqus
Included file 'custom/after_footer.html' not found in _includes directory