objective c - how to solve run time error of [__NSCFString _isResizable]: unrecognized selector sent to instance? -


i beginner of iphone, in code getting run time error of terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[__nscfstring _isresizable]: unrecognized selector sent instance 0x6e6e300'

my code is

- (void)viewdidload { [super viewdidload]; nsstring *path=[[nsbundle mainbundle] pathforresource:@"animalfile" oftype:@"plist"]; nsdictionary *dict=[nsdictionary dictionarywithcontentsoffile:path]; nsarray *animal=[dict valueforkey:@"image"]; nslog(@"print:%@",dict); nslog(@"hello:%@",animal); uiimage *img=[animal objectatindex:currentimage]; [animalphoto setimage:img]; } 

give suggestion , source code apply in code....

the problem happens when attempt treating string image:

uiimage *img = [animal objectatindex:currentimage]; 

the value inside animal array cannot image, because array comes dictionary dict read file using dictionarywithcontentsoffile: method. this method create objects of types nsstring, nsdata, nsdate, nsnumber, nsarray, or nsdictionary. uiimage not on list of types can created dictionarywithcontentsoffile: method, cast invalid.

from error message appears getting nsstring instead of uiimage. check value of string see represents: url, file name, or other form of identifier can used obtain image. depending on what's in string, change program load img rather based on value of string. perhaps code should be

uiimage *img = [uiimage imagenamed:[animal objectatindex:currentimage]]; 

but impossible tell sure without knowing value of string.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -