如何将ID与Iphone中的值进行比较

时间:2010-09-06 09:12:34

标签: objective-c iphone-sdk-3.0

请参阅以下代码,

-(void) dataFromURL:(NSString *)url withRef:(id)ref
{

if(ref==@"Category")
     Printf("category");       //I need control here but control doesn't come here.<br>  
else
     printf("Subcategory");

}

我如何将id数据类型(ref)与类似的值进行比较?当我通过NSLog(@"ID %@",ref);打印参考时,它在角括号中以类别:0xd28f50 返回。

1 个答案:

答案 0 :(得分:0)

它很简单......我明白了 [ref isKindOfClass:[Category class]]。

:)