tags:

views:

13

answers:

2

Hi,

i would like to know how i can access the name of an image when the syntax is something like that:

 NSArray* imgArray =[[NSArray alloc] initWithObjects: 
    [UIImage imageNamed:@"test_01.png"], 
    [UIImage imageNamed:@"test_02.png"], 
    [UIImage imageNamed:@"test_02.png"], nil];

If i print out a specific index, i get the address.

NSLog(@"TEST: %@", [imgArray objectAtIndex:1]);

Output:

TEST: <UIImage: 0x4b12cd0>

How do i get the stringvalue? Any ideas? Thanks for your time.

A: 

You should keep track of the string values yourself. The UIImage object is somewhat closed with respect to the data backing the image.

You could of course subclass UIImage and implement

+(UIImage*)imageNamed:(NSString*)name
{
    self.keepName = name;
    return [super imageNamed:name];
}

adding a keepName string property, but I wouldn't see why you would.

mvds
A: 

UIImage does not expose the name of file it was initialized with. There is no way to access it from the image object.

Ole Begemann
Ok thanks, i understand. I´ve solved it by creating the NSArray only with stringValues and do that UIImage-loading later. Thanks for your help.
geforce