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?

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s