Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-27-2009, 10:43 PM   #1 (permalink)
iPhone Developer
 
Join Date: Jul 2009
Location: Eugene, Oregon
Posts: 97
Default UIImage UIImageView memory question

Hello, I am just curious about an efficient way of using a UIImageView that changes images frequently. I have read that the +imageNamed: method is good because it will cache the loaded image after the first time it is loaded.

Basically, I have a UIImageView object, and it switches between two different images. Should my object store two NSStrings with the paths to these objects, and then call:

Code:
if (setFirstImage)
  [imageViewObject setImage:[UIImage imageNamed:string1]];
else
  [imageViewObject setImage:[UIImage imageNamed:string2]];
Or is it more efficient to simply store the UIImage objects as instance variables inside of my UIImageView object, and then switch between them like so:

Code:
if (setFirstImage)
  [imageViewObject setImage:firstImage];
else
  [imageViewObject setImage:secondImage];
From what I understand, the first way would be better, because the imageViewObject would not need to store as much information about itself, but I haven't really found much information about UIImageViews, so any tips would be greatly appreciated!

Brian
williamsbm2000 is offline   Reply With Quote
Old 08-27-2009, 10:58 PM   #2 (permalink)
iPhone Developer
 
Join Date: Jul 2009
Location: Eugene, Oregon
Posts: 97
Default

Quote:
From what I understand, the first way would be better, because the imageViewObject would not need to store as much information about itself, but I haven't really found much information about UIImageViews, so any tips would be greatly appreciated!
Okay, that was a silly question. I know that either way, it is only storing a POINTER to the objects, not the UIImage or NSString objects themselves. What I am wondering, is that if I use a pointer to a UIImage, if it will only load the image on the first imageNamed: call, as opposed to loading it more (possibly) by calling imageNamed:string every time I need to switch images? Thanks,

Brian
williamsbm2000 is offline   Reply With Quote
Reply

Bookmarks

Tags
memory, uiimage, uiimageview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 268
17 members and 251 guests
ADY, Alsahir, dacapo, Dani77, Desert Diva, Duncan C, F_Bryant, Grinarn, HemiMG, jansan, linkmx, M@realobjects, macquitzon216, prchn4christ, smethorst, spiderguy84
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,882
Threads: 89,228
Posts: 380,761
Top Poster: BrianSlick (7,129)
Welcome to our newest member, jansan
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:47 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0