iOS Simple Image Question..

xArtx

macrumors 6502a
Original poster
Mar 30, 2012
764
1
Hi Guys,

Just starting out here...

Code:
            UIImage *myImage = [UIImage imageNamed:@"imageArt.PNG"];
            CGPoint imagePoint = CGPointMake(156, 53);
            [myImage drawAtPoint:imagePoint];
Does this code read the image from the device's flash every time it occurs?
If so, how can I separate it so the image is loaded just once and can be
printed to the screen multiple times?

Cheers, Art.
 

ArtOfWarfare

macrumors G3
Nov 26, 2007
8,611
4,088
I happen to know this one off the top of my head because I wondered the same thing roughly a year ago, but I'll point out how I learned the answer:

I checked Apple's docs.

From Apple's UIImage Class Reference, in the section for the imageNamed: method
Discussion
This method looks in the system caches for an image object with the specified name and returns that object if it exists. If a matching image object is not already in the cache, this method loads the image data from the specified file, caches it, and then returns the resulting object.
 

xArtx

macrumors 6502a
Original poster
Mar 30, 2012
764
1
I happen to know this one off the top of my head because I wondered the same thing roughly a year ago, but I'll point out how I learned the answer:

I checked Apple's docs.

From Apple's UIImage Class Reference, in the section for the imageNamed: method
So it looks like I can reuse exactly the same three lines even if I print the picture to the screen a hundred times...
Thanks :)
 

ArtOfWarfare

macrumors G3
Nov 26, 2007
8,611
4,088
So it looks like I can reuse exactly the same three lines even if I print the picture to the screen a hundred times...
Thanks :)
I am a little confused why you're using the other two lines instead of a UIImageView.
 

xArtx

macrumors 6502a
Original poster
Mar 30, 2012
764
1
I'm drawing 11x11 pixel bitmap icons over a gps map drawn with quartz 2d.
This is basically how I'm drawing the icon at the same screen point that a plain
Point Of Interest dot would be displayed.

I've read here:
http://xcodenoobies.blogspot.com.au/2011/02/best-way-to-use-uiimageview-memory.html
That this way to print images never frees the memory, but it also says it's faster than
the alternative the tutorial demonstrates.
 

Similar threads

  • PinkyMacGodess
2
Replies
2
Views
407
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.