iPhone – Get Class Name

Sometimes, you may need to find out the class name of an object. A typical example is that when you want to check what is added to a UIView.

for (UIView *subview in self.view.subviews) {
	NSLog(@"%@", NSStringFromClass([subview class]));
}

 

Check the debug log

2010-08-04 14:54:07.545 Test[22308:207] UIProgressView
2010-08-04 14:54:07.546 Test[22308:207] UILabel
2010-08-04 14:54:07.546 Test[22308:207] UILabel
2010-08-04 14:54:07.547 Test[22308:207] UIImageView
2010-08-04 14:54:07.547 Test[22308:207] TouchDragHitView

 

Done =)

Reference: StackOverflow – How to get class name of object in objective c?

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.