Re: How to get the class name in Swift?
Re: How to get the class name in Swift?
- Subject: Re: How to get the class name in Swift?
- From: Quincey Morris <email@hidden>
- Date: Wed, 30 Jul 2014 00:59:54 -0700
On Jul 30, 2014, at 00:02 , Gerriet M. Denkmann <email@hidden> wrote:
How to translate this: NSString *className = [ [ someObject class ] description ]; into Swift?
AFAICT, there isn’t any equivalent mechanism built into Swift yet. The two best answers I could find:
1. (from StackOverflow) Use NSStringFromClass (someObject.dynamicType), though this gives a mangled class name.
2. (from an example in the Swift book) Write a class method in each class you want to inspect, that returns a string literal for the readable class name. You can put the name of this method in a protocol to which each such class would conform.
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden