How to pass values by reference in objective C (iphone)

后端 未结 6 858
长发绾君心
长发绾君心 2020-12-02 09:03

I have a very basic question. I\'m a new iPhone programmer. My question is can anybody tell me how can I pass values by reference to a function in obj. C? I know how to do

6条回答
  •  没有蜡笔的小新
    2020-12-02 09:32

    Try this way :

        -(void)secondFunc:(NSInteger*)i
        {
          *j=20;
         //From here u can change i value as well
         //now i and j value is same (i.e i=j=20)
        }
        -(void) firstFunc
        {
           NSInteger i=5;
          [self secondFunc :&i];
         //i value is 20
        }
    

    Hope it helps!!

提交回复
热议问题