Pass data from method to method

60 Views Asked by At
- (void) getArrray : (NSArray*)arrray{
NSLog(@"Get Array %@",arrray);
}

-(DraggableView *)createDraggableViewWithDataAtIndex:(NSInteger)index
{
      draggableView.information.text = [exampleCardLabels objectAtIndex:index]
}

I want the arrray data to examplecardlabels with out disturbing the methods. How could I get the data to createdraggable method from getdata method

please help me in this.

1

There are 1 best solutions below

8
On

Make either a property or a global variable in this class, then set it in the one method and read the value in the other method.

@implementation myClass 
{
   NSArray* myArrayData;
}

- (void) getArrray : (NSArray*)arrray{
   NSLog(@"Get Array %@",arrray);
   myArrayData = array;
}

-(DraggableView *)createDraggableViewWithDataAtIndex:(NSInteger)index{
   draggableView.information.text = [myArrayData objectAtIndex:index];
}
}