Actually hold on.  Do we want to support files loaded by reference?  At which point the path could be [mainBundle pathForResource:@“/myCustomFolder/image” ofType:@“png”]

`imageNamed:` won’t handle this case


On Nov 22, 2013, at 3:41 PM, Jonas Budelmann <notifications@github.com> wrote:

> In Classy/Parser/CASStyleProperty.m:
> 
> > +        if([scheme isEqualToString:@"caches"]) {
> > +            searchMask = NSCachesDirectory;
> > +        } else if([scheme isEqualToString:@"documents"]) {
> > +            searchMask = NSDocumentDirectory;
> > +        } else if([scheme isEqualToString:@"bundle"]) {
> > +            NSArray *parts = [path componentsSeparatedByString:@"."];
> > +            NSString *iPath = [parts firstObject];
> > +            NSString *ext = [parts count] > 1 ? [parts lastObject] : @"png";
> > +            imagePath = [[NSBundle mainBundle] pathForResource:iPath ofType:ext];
> > +        }
> > +        
> > +        if(searchMask != 0) {
> > +            NSArray *paths = NSSearchPathForDirectoriesInDomains(searchMask, NSUserDomainMask, YES);
> > +            imagePath = [paths firstObject];
> > +        }
> > +        imageValue = [UIImage imageWithContentsOfFile:[imagePath stringByAppendingPathComponent:path]];
> would this work? then we can remove the whole else if([scheme isEqualToString:@"bundle"]) block
> 
> if(searchMask != 0) {
>     NSArray *paths = NSSearchPathForDirectoriesInDomains(searchMask, NSUserDomainMask, YES);
>     NSString *imagePath = [paths firstObject];
>     imageValue = [UIImage imageWithContentsOfFile:[imagePath stringByAppendingPathComponent:path]];
> } else {
>     imageValue = [UIImage imageNamed:path];
> }
> —
> Reply to this email directly or view it on GitHub.
>