I have one problem I want to call a function and use the value I get from that function, here is the code of my function
-(double)CellWidth{
double width;
if([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait || [[UIDevice currentDevice]orientation] == UIDeviceOrientationPortraitUpsideDown){
NSLog(@"Device is now in Portrait Mode");
width = 153.6;
}
if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft || [[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight) {
NSLog(@"Device is now in LandscapeLeft Mode ");
width = 204.6;
}
return width;
}
that function is in Class1.m but I also declared in Class1.h like this
-(double)CellWidth;
now I want to use it in Class2
code in Class2.h
#import "Class1.h"
@interface ...
{
Class1 *class1;
}
@property (nonatomic,release) Class1 *class1;
Class2.m
I want to use this
self.TableView.rowHeight = [class1 CellWidth];
But the CellWidth is not getting called and I am not receiving the width.
You’re not passing in a parameter.
You should have something like this:
The reason your current implementation isn’t calling that function is because you aren’t telling it to call that function. You’re telling it to call
[function CellWidth]not[function CellWidth:orientation]Based upon your feedback, you actually seem to want something more like this:
then in your implementation, in Class2.m:
To make this even clearer, I am going to try and clean up this…
CoolCellInfo.h
CoolCellInfo.m
CoolCellUser.h
CoolCellUser.m