void PrintIntrospectionInfo()
{
// NSLog(@"Comes here1");
NSArray *myArray;
NSDate *aDate = [NSDate distantFuture];
NSValue *aValue = [NSNumber numberWithInt:5];
NSURL *urlObj = [NSURL URLWithString:@"http://www.yahoo.com"];
NSString *aString = @"string";
NSMutableString *mString = [NSMutableString stringWithFormat: @"Hello, %@", aString];
NSDictionary *stanford = [NSDictionary dictionaryWithObjectsAndKeys:@"http://www.stanford.edu", @"Stanford University", @"http://www.apple.com",@"Apple", @"http://cs193p.stanford.edu", @"CS193P",@"http://itunes.stanford.edu",@"Stanford on iTunesU",@"http://stanfordshop.com",@"Stanford Mall", nil];
myArray = [NSArray arrayWithObjects:aDate, aValue, aString,stanford,urlObj,mString, nil];
for(id someObject in myArray)
{
NSLog(@"Comes here");
if([someObject isKindofClass:[NSString string]])
{
}
}
}
答案 0 :(得分:2)
待办事项
for(id someObject in myArray)
{
NSLog(@"Comes here");
if([someObject isKindOfClass:[NSString class]])
{
}
}
代替。请注意Of
的{{1}}是大写的。我建议您使用isKindOfClass
代替NSObject*
。然后编译器警告您方法id
不可用。通常,除非您使用的内容不是isKindofClass
,否则您无需使用id
:
NSObject