Linked Questions

4 votes
2 answers
4k views

I have a viewController called 'MyViewController' in which I want to save some values to the user defaults. As key I wanted to use the class name "MyViewController" and append some string. Is it ...
borchero's user avatar
  • 6,112
-3 votes
1 answer
1k views

I am using the following syntax to debug my Objective C code, getting the class name. What is the equivalent in SWIFT? NSlog (@"Classe = %@",[self class]);
Ing. Ron's user avatar
  • 2,105
0 votes
1 answer
85 views

Apologies for the title gore, but I can't really think of any other way to phrase it. I am a Swift noob and am trying to make a silly little program for practice. Anyway, I have superclass which I ...
Produces's user avatar
367 votes
34 answers
271k views

Is there a way to print the runtime type of a variable in swift? For example: var now = NSDate() var soon = now.dateByAddingTimeInterval(5.0) println("\(now.dynamicType)") // Prints "(Metatype)" ...
Matt Bridges's user avatar
  • 49.6k
327 votes
20 answers
311k views

I have an array that is made up of AnyObject. I want to iterate over it, and find all elements that are array instances. How can I check if an object is of a given type in Swift?
Encore PTL's user avatar
  • 8,254
125 votes
7 answers
65k views

I am trying to dynamically create a class instance based type using generics, however I am encountering difficulty with class introspection. Here are the questions: Is there a Swift-equivalent to Obj-...
Erik's user avatar
  • 12.9k
27 votes
4 answers
24k views

If I have a UIViewController subclass, how can I get the class name as string? I've tried doing [vc class], but this returns a Class object, not an NSString.
xonegirlz's user avatar
  • 8,929
18 votes
3 answers
15k views

I have a static method in Swift class BaseAsyncTask: WebServiceClient { class func execute(content : [String:AnyObject], cancelled:CustomBool) { // Print class name (...
Oscar Vasquez's user avatar
2 votes
1 answer
6k views

I recently upgraded my project to Swift and I'm trying to figure out how to instantiate my XIBs dynamically while maintaining strong references to my viewcontrollers. I hate having to call NSBundle....
Oren's user avatar
  • 5,083
0 votes
3 answers
2k views

Recently I started getting this error from Xcode: Error Screenshot This 'className' property belongs to NSObject. Here is the official documentation. Why is this happening and how do I solve this (...
ZanYzer's user avatar
  • 45
1 vote
3 answers
995 views

In Objective-C I can do this: @interface MyManagedObjectSuperClass : NSManagedObject +(NSString*)entityName; @end @implementation +(NSString*)entityName { return NSStringFromClass([self class]) ...
MeloS's user avatar
  • 7,948
2 votes
1 answer
2k views

In Objective-C, I subscribed to the UIWindowDidBecomeVisibleNotification to know if some view gets above my current view controller, using: [[NSNotificationCenter defaultCenter] addObserver:self ...
Alejandro Iván's user avatar
0 votes
0 answers
167 views

From this answer, I know that I can get the name of the class type using NSStringFromClass(YourClassName) But I actually also need the name of the current object instance. So if I have code like this:...
Chen Li Yong's user avatar
  • 6,177