i want to create some header file for future use but i have 1 problem
i have defined a method in lets say Rimage class called check1
now i want to call that from maiviewcont
so i did this
in mainVC.h
i defined a instance of Rimage class
#import <UIKit/UIKit.h>
@class Rimage;
@interface Rahul_imageplaceCordinatesViewController : UIViewController {
Rimage *aRimage;
}
@property (nonatomic,copy) Rimage *aRimage;
@end
and in .m
[self.aRimage check1];
aRimage = [Rimage check1];
but both are not working
i went for both +(void)check1 and -(void)check1 in Rimage class
The two examples you give do very different things:
invokes an
check1instance method onaRimage.calls the
check1class method on theRimageclass, and assigns the result toaRimage.In both cases, you will need to
#import "Rimage.hin your .m file, else you’ll get warnings like “aRimage may not respond to ‘check1′”.EDIT
Your “.h” file is declaring a property named “aRimage”, but that value will be nil until you assign something to it, by doing something like:
See this question for a good explanation of the difference between class methods and instance methods.
ps. and don’t forget to do a
[aRimage release]in your dealloc method