Ad
How Can I Call A Method Written In Class1 To Class2?
I have class1.m . I declared a method and written in it. Now i need to call it into another class. How can I make it? Can we use extern for it like we use for variables. Thank you.
Ad
Answer
You should separate your declaration and definition, and place the declaration for class1 in class1.h. Then, you should include class1.h using #import "class1.h"
in your source file for class2. Within class2, you can instantiate and use class1 as follows:
class1* instance_of_class1 = [[class1 alloc] init]; [class1 invokeMyMethod];
When you are done using your instance, be sure to decrement the reference count via release as in:
[instance_of_class1 release]; instance_of_class1 = nil;
Ad
source: stackoverflow.com
Related Questions
- → OctoberCMS Backend Loging Hash Error
- → "failed to open stream" error when executing "migrate:make"
- → OctoberCMS - How to make collapsible list default to active only on non-mobile
- → Create plugin that makes objects from model in back-end
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → How to install console for plugin development in October CMS
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → How to update data attribute on Ajax complete
- → October CMS - Conditionally Load a Different Page
Ad