iphone - Storing/Extracting Objects to/from NSDictionary -
i getting errors using nsdictionary when trying assign it's contents new variables/objects. maybe isn't posible? thought be. i'm not sure if can use non-objective c specific objects in dictionary. can you?
nsdictionary *preprocessresult = [[nsdictionary alloc] initwithdictionary: [self preprocessing:testimage]]; iplimage* resultimage = [preprocessresult objectforkey:@"resultimage"]; int numchars = [preprocessresult objectforkey:@"numberchars"]; [preprocessresult release];
and here method calling create dictionary:
- (nsdictionary*) preprocessing: (iplimage*) testimage { //do stuff image nsdictionary *testimage_andnumchars = [nsdictionary dictionarywithobjectsandkeys:resultimage, @"resultimage", numchars, @"numberchars", nil]; return testimage_andnumchars; }
is not correct way handle this? error when create dictionary is:
"cannot convert 'iplimage*' 'objc_object*' in argument passing"
and when retrieve dictionary elements get:
"cannot convert 'objc_object*' 'iplimage*' in initialization" , "invalid conversion 'objc_object*' 'int' ".
i've read apple docs on nsdictionary got me far, not sure go here.
thanks in advance.
putting shortly, nsdictionary
values must nsobject
s.
you should store int
nsnumber
using e.g.:
[nsnumber numberwithint:numchars]
when retrieving value can use e.g.:
int numchars = [[preprocessresult objectforkey:@"numberchars"] intvalue];
Comments
Post a Comment