objective c - How to store images and refere to it for my iOS interface? -
i'm using xcode 6.
let's have food model containing (uiimage *)image property. display foods displaying images interface. have pictures foods (they not in photo library of device on computer).
1) put these image files (beet.png, banana.png etc... example) in xcode ? (is there dedicated folder ?)
2) how refere image file ? example in food class, self.image = ?
thanks lot !
you can drag , drop image files project while xcode open.
make sure use copy items if needed option, less hassle.
once clikc finish files, see files on bundle.

then need call [uiimage imagenamed:@"imageinbundle.png"]; imagenamed: search main bundle
or long way
nsbundle* bundle = [nsbundle bundlewithurl:[[nsbundle mainbundle]urlforresource:@"yourbundle" withextension:@"bundle"]]; nsstring *imagepath = [bundle pathforresource:@"imageinbundle" oftype:@"png"]; uiimage* image = [uiimage imagewithcontentsoffile:imagepath];
Comments
Post a Comment