Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6852227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:20:44+00:00 2026-05-27T01:20:44+00:00

I have one problem I want to call a function and use the value

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:20:45+00:00Added an answer on May 27, 2026 at 1:20 am

    You’re not passing in a parameter.

    You should have something like this:

    [self setClass1:[[[Class1 alloc] init] autorelease]];
    
    UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
    
    //This
    [[self horizontalTableView] setRowHeight:[class1 CellWidth:orientation]];
    

    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:

    -(double)CellWidth {
        double width = 0;
    
        UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
    
        if(orientation == UIInterfaceOrientationPortrait) {
            NSLog(@"PORTRAIT");
            width = 153.6;
        } else if(orientation == UIInterfaceOrientationLandscapeLeft ||
                    orientation == UIInterfaceOrientationLandscapeRight) {
            NSLog(@"LANDSCAPE");
            width = 204.6;
        }
    
        return width;
    
    }
    

    then in your implementation, in Class2.m:

    [self setClass1:[[[Function alloc] init] autorelease]];
    
    //This
    [[self horizontalTableView] setRowHeight:[class1 CellWidth]];
    

    To make this even clearer, I am going to try and clean up this…

    CoolCellInfo.h

    @interface CoolCellInfo : NSObject {
    
    }
    
    -(double)cellWidth;
    
    @end
    

    CoolCellInfo.m

    @implementation CoolCellInfo
    
    -(id)init {
        self = [super init];
    
        if(self) {
    
        }
    
        return self;
    }
    
    -(double)cellWidth {
        double width = 0;
    
        UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
    
        if(orientation == UIInterfaceOrientationPortrait) {
            NSLog(@"PORTRAIT");
            width = 153.6;
        } else if(orientation == UIInterfaceOrientationLandscapeLeft ||
                    orientation == UIInterfaceOrientationLandscapeRight) {
            NSLog(@"LANDSCAPE");
            width = 204.6;
        }
    
        return width;
    }
    
    @end
    

    CoolCellUser.h

    #import "CoolCellInfo.h"
    
    @interface CoolCellUser : NSObject {
        CoolCellInfo *cellInfo;
    }
    
    @property (nonatomic, retain) CoolCellInfo *cellInfo;
    
    @end;
    

    CoolCellUser.m

    @implementation CoolCellUser
    @synthesize cellInfo;
    
    -(id) init {
        self = [super init];
    
        if(self) {
             double width = [[self cellInfo] cellWidth];
    
             NSLog(@"Omg cell width = %f", width);
        }
    
        return self;
    }
    
    #pragma mark Lazy Loader
    -(CoolCellInfo *)cellInfo {
        if(cellInfo == nil) {
            [self setCellInfo:[[[CoolCellInfo alloc] init] autorelease]];
        }
    
        return cellInfo;
    }
    
    @end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one problem , I want to get some data from XML file
I'm almost finished with my program, but I have one problem that I can't
I have one interesting problem. I must parse mail body (regular expression), get some
The problem: we have one application that has a portion which is used by
I have problem with session in cakephp.I have one file chat.php that is in
One problem that I come across regularly and yet don't have a solution to
I have a problem since three days about google map. I want to use
I want that diffrent events to call the same function. I read other post,
I have one problem to work with NSMutableData . I defined one NSMutableData *receivedData
I have one problem, I learn how work with socket and I write programm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.