Monday, January 18, 2010

UIView class-anak ellenorzese

Ha egy public class-rol van szo (pl UILabel) akkor konnyu megnezni:

if ([myView isKindOfClass:[UILabel class]]{

NSLog(@"myView is a UILabel");

}

de ha egy private class-ra akarom ellenorizni (pl MPFullScreenTransportControls) akkor az igy mar le sem fordulna. Ilyenkor ez is egy lehetseges megoldas:

NSString *className = NSStringFromClass([myView class]);

if (NSOrderedSame == [className compare:@"MPFullScreenTransportControls"]) {

//...

}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.