Getting class name in SWIFT equivalent to Objective C [self class]? [duplicate] - objective-c

This question already has answers here:
Get class name of object as string in Swift
(32 answers)
Closed 3 years ago.
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]);

You can use print("Class = \(type(of: self))" in Swift.

Related

Objective-C to Swift 3 Method Name Change Issue [duplicate]

This question already has an answer here:
Use objective-c method in swift seems crossing keyword of swift language
(1 answer)
Closed 6 years ago.
I am trying to use a method from Objective-C in Swift 3, but Swift 3 is translating the signature to something invalid for the compiler.
- (void)doWhenReady:(void(^)(void))block onDone:(ErrorCallback)callback;
Gets translated to
do(whenReady: ()->(), onDone: ErrorCallback)
Where do becomes the keyword do and invalid syntax for the method. What solutions do I have to fix this without refactoring the Objective-C code?
In the Swift expression do(whenReady..., write do with backtick characters around it.

How to access enum from swift to Objective C [duplicate]

This question already has answers here:
How to pass swift enum with #objc tag
(2 answers)
Closed 7 years ago.
I have created enum in swift. I want to set value to enum in objective C. I am unable to get enum value in Objective C. Gratitude for your help.
Just mark the enum by #objc like this:
#objc enum FitMode: Int {
case Clip, Crop, Scale
}

Creating a Map<Object,Array<Object>> in objective c [duplicate]

This question already has answers here:
What is the Java equivalent of Objective-C's NSDictionary?
(3 answers)
Closed 9 years ago.
I am interested in creating the java equivalent of a Map data structure that looks as follows:
Map <Object ---> NSMutableArray of objects>
or
Map<Object,Array<Object>>
Can anyone provide guidance on what would be the best way of doing this in objective c as I am fairly new to the language.
Objective-c does not have typed collections. You just create NSMutableDictionary instance, and put NSMutableArray into the values.

calling objective c method from c function [duplicate]

This question already has answers here:
How to call an Objective-C Method from a C Method?
(5 answers)
Closed 9 years ago.
I tried doing this in my objective C method
my_function(self);
my_function(void *param)
{
id self = param;
[self.Output insertText:#"Hello world"];
}
Output is of type NSTextView.
I get the following errors in compilation
Use of undeclared identifier 'id' in the line "id self = param".
I tried #import <Cocoa/Cocoa.h>, but didn't help. In the line [self.Output insertText:#"Hello world"];, I get "Expected expression" error.
Basically, what i am trying to do is to share some data periodically between my c function(where it's generated) and objective c method(where it's processed and displayed). I am total newbie in objective c, any help is greatly appreciated. If there is a better way to do this than calling objective c methods from C function, I am open to that.
You can not use objektive-c in .c files. But you can use c in .m files so if you need to mix make sure its a .m file.

How to call a method in Objective-C? [duplicate]

This question already has answers here:
How can I call a method in Objective-C?
(8 answers)
Closed 9 years ago.
I am just starting out in ios and am trying to make user defined functions...
my code:
-(void) testFunction{
//has self. calls
}
-(IBAction)button:(id)sender {
testFunction();
}
I get the warning: Implicit declaration of function is invalid in C99
What am I doing wrong? Or what do I have to add to my code?
In Objective-C you cant write testFunction(). You send 'messages' and you can do this via
[self testFunction]