I just tested it after change, it works, but isse appears on the next step
if I try to use this variable later, it is lost.
I changed objects names to make analysis easier:
//my method in my object OBJ2
{
[delegate didSelectItemAtIndex:[self methodreturningnumber]];
}
in my delegate (OBJ1) I have method:
-(void)didSelectItemAtIndex:(NSNumber *) NSNUMBER
{
SliceDetailsViewController * OBJ2 = [[SliceDetailsViewController alloc] initWithNibName:nil bundle:nil];
OBJ2. NSNUMBER = NSNUMBER; // <---------- THIS IS LOST IF I DON'T ADD RETAIN [NSNUMBER retain]
OBJ2.pieChart = graphView;
OBJ2.myColors=myColors;
[self presentModalViewController:sliceDetailsController animated:YES];
[sliceDetailsController release];
}
in my modalWindow (OBJ3) I have method which is called from it's subview OBJ4
- (void)colorPicker:(ColorPicker *)myColorPicker didSelectItemAtIndex:(NSNumber *)indexPath
{
[OBJ2 setColor:NSNUMBER value:indexPath]; // <------ SLICEID IS NOT AVAILABLE HERE IF NOT RETAINED IN PREVIOUS OBJECT
}
OBJ4 calls this method above:
[delegate colorPicker:self didSelectItemAtIndex:atrribute];
...........
called methods are from objects:
OBJ1-->OBJ2-->OBJ1-->OBJ3-->OBJ4-->OBJ3
OBJ1 call OBJ2 (passing self as delegate)
OBJ2 generates NSNumber X and call method of OBJ1 with NSNumber X
OBJ1 call as presentModalViewController OBJ3 and sets X as one of attributes of OBJ3
OBJ3 is displayed properly and can access NSNumberX
OBJ3 VievController class subview OBJ4 (view displayed on the same screen)
when I click on OBJ4 it calls method of OBJ3 without arguments
and OBJ3 has address of NSNumber, but it is out of scope.
..........