memory management - Objective - C calling variable not working -


i have variable defined here:

const sdatagridcoord *clickedgridcoord; 

and populating in method:

- (void)shinobidatagrid:(shinobidatagrid *)grid willselectcellatcoordinate:(const sdatagridcoord *)gridcoordinate {     if ((gridcoordinate.column.displayindex==5||gridcoordinate.column.displayindex == 6 || gridcoordinate.column.displayindex == 7 ) && datasource.datafordatabase)     {         clickedgridcoord  = gridcoordinate;         [self createcelldatemodpopup:gridcoordinate];     } } 

and used break point , see being populated.

but when goto call it, empty:

celldata *cell = [datasource.cellholder objectatindex:clickedgridcoord.row]; 

and empty mean there no row or column, there when first populate sdatagridcoord.

what doing wrong, there nothing else overriding variable.

i have tried this:

sdatagridcoord *clickedgridcoord; 

then

- (void)shinobidatagrid:(shinobidatagrid *)grid willselectcellatcoordinate:(const sdatagridcoord *)gridcoordinate {     if ((gridcoordinate.column.displayindex==5||gridcoordinate.column.displayindex == 6 || gridcoordinate.column.displayindex == 7 ) && datasource.datafordatabase)     {         clickedgridcoord = (sdatagridcoord *)gridcoordinate;         [self createcelldatemodpopup:gridcoordinate];     } } 

still same result , app still crashes: thread 1:exc_bad_access (code = 1, address=0xc000000c)

my .m file:

@interface controller() {      sdatagridcoord *clickedgridcoord; }  @implementation controller  - (void)shinobidatagrid:(shinobidatagrid *)grid willselectcellatcoordinate:(const sdatagridcoord *)gridcoordinate {     if ((gridcoordinate.column.displayindex==5||gridcoordinate.column.displayindex == 6 || gridcoordinate.column.displayindex == 7 ) && datasource.datafordatabase)     {         clickedgridcoord = (sdatagridcoord *)gridcoordinate;         [self createcelldatemodpopup:clickedgridcoord];     } }   - (void)changecellwithstringdate :(nsstring *)stringdate {     //my app crashes here error: thread 1:exc_bad_access (code = 1, address=0xc000000c)     celldata *cell = [datasource.cellholder objectatindex:clickedgridcoord.row.rowindex]; } 

are using pre-arc library? if suspect (and mean code) manually releasing 1 more time object referenced gridcoordinate.

this cause object deallocated , end reference wrong memory location (because object gone).

if have source code of sdatagridcoord please add breakpoint in dealloc method , if gets called before try use object in

- (void)changecellwithstringdate :(nsstring *)stringdate 

finally, if happening should create sdatagridcoord object (a copy yours) , assigning ivar. managed arc , fine.