I have resources:
Test.png
test1.jpg
tesT2.jpg
tEst3.jpg
I need to show this image in UIImageView. So I wrote:
imgView.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[myObject.filename stringByDeletingPathExtension] ofType:[myObject.filename pathExtension]]];
myObject is entity in my model. I get filename from xml, but in xml it have format like:
filename="test.png"
filename="test1.jpg"
filename="test3.jpg"
filename="test3.jpg"
So my Image is (null) because in pathForResource I search @"test" ofType "png", but need @"Test" ofType"png".
How I can get correct resources without renaming them?
If you can't rename the source data (which you should do really), then you would need to use the file manager to get a list of all of the files available and then do a case insensitive filter to get the matching name and use that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With