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]])
{
}
}
}发布于 2011-09-19 18:41:51
做
for(id someObject in myArray)
{
NSLog(@"Comes here");
if([someObject isKindOfClass:[NSString class]])
{
}
}而不是。注意,isKindOfClass的Of是大写的。我建议您使用NSObject*而不是id。然后,编译器会警告您isKindofClass方法不可用。通常,除非您使用的不是NSObject,否则不需要使用id:
for(NSObject* someObject in myArray)https://stackoverflow.com/questions/7469562
复制相似问题