i have method returns card*
nsobject (to clear, object of own invention, correctly , define in card.h , card.m):
-(card*)readcardfromarraywithcustomobjfromuserdefaults:(nsindexpath *)indexpath; { nsdata *existingdata = [[nsuserdefaults standarduserdefaults] objectforkey:@"deck"]; // if no such data exists, return nil if (existingdata == nil) return nil; nsarray *existingdeck = [nskeyedunarchiver unarchiveobjectwithdata:existingdata]; return [existingdeck objectatindex:indexpath.row]; }
it seems clear me should return card*
, , yet, when call method, this:
card* selectedcard = readcardfromarraywithcustomobjfromuserdefaults(indexpath);
i warning:
implicit conversion of 'int' 'card*' disallowed arc
i thought maybe issue didn't cast card*
before returning, if change readcardfromarraywithcustomobjfromuserdefaults
method explicitly cast such, still same warning:
card* thiscard = [existingdeck objectatindex:indexpath.row]; return thiscard;
to clear, know return card*
, because when put same code in function calling (instead of separating own readcardfromarraywithcustomobjfromuserdefaults
method) card*
. trying slim down code putting oft-used code portion in own method , baffled why not work.
i have tried returning entire nsarray*
of cards instead, causes same warning (just implicit conversion nsarray*
instead of 'card*'). existing answers warning, such this , this not seem related situation (unless missing something).
i have 2 ideas regarding might happening:
maybe fact data being accessed elsewhere in order populate uitableview somehow messing pointer or something.
maybe arc nixing card before can use baffling reason (this sounds because fact compiler seems think
card*
returning method returns int makes me think i'm getting pointer , code reason doesn't understand pointer points @card*
).
what doing wrong?
i feel exceedingly foolish. again, stack overflow place makes happy feel foolish. problem have been coding in c , c# long, called method incorrectly. should have written:
card* thiscard = [self readcardfromarraywithcustomobjfromuserdefaults:indexpath];
instead of:
card* selectedcard = readcardfromarraywithcustomobjfromuserdefaults(indexpath);
Comments
Post a Comment