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 10-27-2009, 12:07 PM   #1 (permalink)
Registered Member
 
Join Date: Oct 2009
Location: Manchester, UK
Posts: 23
Post Using imageNamed - should I avoid this?

Hi all, I'm new here!

I've been working with the SDK for a few days now, and am starting to get the grips with iPhone development (just about!). However, I have encountered a few issues that seem like hot-topics, and just wanted some clarification (if possible).

I've got three image files stored in my project that are ultimately going to be displayed inside a UIImageView (that's been set up inside a NIB using Interface Builder).

Since I'm going to change which image is used inside the view depending on a mode variable, I wanted to know if the following code is suitable?

Code:
// define an image to be used for this mode
UIImage *imgBackground = [UIImage imageNamed:@"imgBack1.png"];

// assign this image to the UIImageView
[iView setImage:imgBackground];
Now, am I correct in thinking that this particular method of assigning a variable is using a convenience method? I.e. It isn't specifically using alloc, copy or retain, and therefore doesn't need a release called upon it? Naturally, I have the
Code:
[iView release]
code in this class's dealloc method.

Is imageNamed the correct method to use to pull images from your library?

Any help would be greatly appreciated.

Thanks!
Obelisk is offline   Reply With Quote
Old 10-27-2009, 12:28 PM   #2 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 79
Default

Quote:
Originally Posted by Obelisk View Post
Hi all, I'm new here!

I've been working with the SDK for a few days now, and am starting to get the grips with iPhone development (just about!). However, I have encountered a few issues that seem like hot-topics, and just wanted some clarification (if possible).

I've got three image files stored in my project that are ultimately going to be displayed inside a UIImageView (that's been set up inside a NIB using Interface Builder).

Since I'm going to change which image is used inside the view depending on a mode variable, I wanted to know if the following code is suitable?

Code:
// define an image to be used for this mode
UIImage *imgBackground = [UIImage imageNamed:@"imgBack1.png"];

// assign this image to the UIImageView
[iView setImage:imgBackground];
Now, am I correct in thinking that this particular method of assigning a variable is using a convenience method? I.e. It isn't specifically using alloc, copy or retain, and therefore doesn't need a release called upon it? Naturally, I have the
Code:
[iView release]
code in this class's dealloc method.

Is imageNamed the correct method to use to pull images from your library?

Any help would be greatly appreciated.

Thanks!
No you would not dealloc the image, and yes that is the appropriate call for an image in the project directory
__________________
iEncourage - Premier Encouragement App for iPhone/iPod Touch
iSleepWell- Premier Sleep Tracking App for iPhone/iPod Touch

iEasyProductions - "Simple, Yet Refined"
ieasyproductions is offline   Reply With Quote
Old 10-27-2009, 12:29 PM   #3 (permalink)
Registered Member
 
Join Date: Oct 2009
Location: Manchester, UK
Posts: 23
Default

Quote:
Originally Posted by ieasyproductions View Post
No you would not dealloc the image, and yes that is the appropriate call for an image in the project directory
That's great, many thanks for your input!
Obelisk is offline   Reply With Quote
Reply

Bookmarks

Tags
convenience, imagenamed, iphone, 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: 305
19 members and 286 guests
ADY, AragornSG, BrianSlick, Dani77, Dattee, dre, glenn_sayers, HDshot, HemiMG, JasonR, karlam963, prchn4christ, Rudy, spiderguy84, themathminister, tomtom100, viniciusdamone, vogueestylee, vvenkatachallam
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,884
Threads: 89,229
Posts: 380,763
Top Poster: BrianSlick (7,129)
Welcome to our newest member, karlam963
Powered by vBadvanced CMPS v3.1.0

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