How to share a void in two files

I have two files. I build a void in one of the files and I want two files to share this void. Can I use the keyword extern? If yes, how to write? If no, what can I do? I am using Objective C.Please help me.Thank you.

Replies

You appear to be using the wrong word, "void", to refer to something but you've chosen the wrong word. What did you mean to write?

Thank you but "void" is not a wrong word. It's a code like "int" , "char", "return". The keyword "void"means, the method won't return anything. You can use "void" in this way:


int x;


-(void)addNumber{

x = x + 1;

}

And I want to ask you how to share the same "void" in different files. Can I use the keyword "extern"? Or is there other ways?

Please have a nice day.

What do you mean? Will you help me?

Your use of 'void' in that example is understood, don't worry. What's not clear to me is what you're trying to share and why.


See this Apple document that may help answer your question - see operation tasks and concurrent queues as examples.:


https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html


Ken

Quoting off the 'net...


(void) indicates the return type. '-' indicates that the method is an instance (vs. class) method. It requires an objectto call it, and instance variables of the object are available to it inside its definition.


Which of those are you attempting to share/make available to other files? The return type? Not the method?


About keyword extern, see this SO thread:


http://stackoverflow.com/questions/1433204/how-do-i-use-extern-to-share-variables-between-source-files-in-c


Good luck.