Search code examples
iphoneobjective-ccgrect

how to pass cgrect as parameter and how to get cgrect as a return type in ipad


hi all i am going to ask basic question i searched many links for my question but none of the things not given exact result.here is my question:

I want to pass rect value and returning the same type using some transformation for that i wrote one method but it is giving me the errors i know it may be syntactically wrong please correct the below code

-(void)viewDidLoad{
    CGRect testRect=getNewRect(self.view.frame);
}

my own method is here

CGRect getNewRect(CGRect normalRect){
    //some transformation
    return tranfermedrect;
}

give me your suggestion thanks in advance..


Solution

  • Used following line you will solve your problem.

    [self yourFunction:[NSValue valueWithCGRect:rectFrame]];
    

    Above line is the simple method call and in objective-C you can not send CGRect as a parameter. so you have to CGRect convert into NSValue.

    At called function you have get GGRect from NSValue

    yourView.frame = [rect CGRectValue];
    

    I hope it will help you.