<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: imageNamed is evil</title>
	<atom:link href="http://www.alexcurylo.com/blog/2009/01/13/imagenamed-is-evil/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.alexcurylo.com/blog/2009/01/13/imagenamed-is-evil/</link>
	<description>Alex Curylo, iPhone Programmer</description>
	<lastBuildDate>Tue, 07 Feb 2012 06:22:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Klaus Busse</title>
		<link>http://www.alexcurylo.com/blog/2009/01/13/imagenamed-is-evil/comment-page-2/#comment-7513</link>
		<dc:creator>Klaus Busse</dc:creator>
		<pubDate>Fri, 18 Nov 2011 17:44:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.alexcurylo.com/blog/?p=386#comment-7513</guid>
		<description>There&#039;s a single case where imageNamed has it&#039;s merits: If you have small files, that you use over and over, typically ressources. For everything else, DONT.</description>
		<content:encoded><![CDATA[<p>There&#8217;s a single case where imageNamed has it&#8217;s merits: If you have small files, that you use over and over, typically ressources. For everything else, DONT.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: imageNamed is evil « Under The Bridge &#171; Brainwash Inc. &#8211; iPhone/Mobile Development</title>
		<link>http://www.alexcurylo.com/blog/2009/01/13/imagenamed-is-evil/comment-page-2/#comment-7441</link>
		<dc:creator>imageNamed is evil « Under The Bridge &#171; Brainwash Inc. &#8211; iPhone/Mobile Development</dc:creator>
		<pubDate>Wed, 12 Oct 2011 16:31:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.alexcurylo.com/blog/?p=386#comment-7441</guid>
		<description>[...] imageNamed is evil « Under The Bridge. Like this:LikeBe the first to like this [...]</description>
		<content:encoded><![CDATA[<p>[...] imageNamed is evil « Under The Bridge. Like this:LikeBe the first to like this [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: imageNamed is evil « Under The Bridge &#171; Brainwash Inc. &#8211; iPhone/Mobile Development</title>
		<link>http://www.alexcurylo.com/blog/2009/01/13/imagenamed-is-evil/comment-page-2/#comment-7440</link>
		<dc:creator>imageNamed is evil « Under The Bridge &#171; Brainwash Inc. &#8211; iPhone/Mobile Development</dc:creator>
		<pubDate>Wed, 12 Oct 2011 16:31:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.alexcurylo.com/blog/?p=386#comment-7440</guid>
		<description>[...] imageNamed is evil « Under The Bridge. Like this:LikeBe the first to like this [...]</description>
		<content:encoded><![CDATA[<p>[...] imageNamed is evil « Under The Bridge. Like this:LikeBe the first to like this [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ClamB</title>
		<link>http://www.alexcurylo.com/blog/2009/01/13/imagenamed-is-evil/comment-page-2/#comment-4772</link>
		<dc:creator>ClamB</dc:creator>
		<pubDate>Mon, 07 Mar 2011 02:00:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.alexcurylo.com/blog/?p=386#comment-4772</guid>
		<description>Many many thanks for this posting.
We just finished a simple slideshow app with 100 200k jpegs, and it failed without fail.  After reading this posting I used the following simple code to load my images, and it now works without fail;

NSString *fromName = [NSString stringWithFormat:@&quot;image%d&quot;, i];
NSString *fromPhotoName = [[NSBundle mainBundle] pathForResource:fromName ofType:@&quot;jpg&quot;];
UIImage *fromPhoto = [UIImage imageWithContentsOfFile:fromPhotoName];

Thanks again,
CPL</description>
		<content:encoded><![CDATA[<p>Many many thanks for this posting.<br />
We just finished a simple slideshow app with 100 200k jpegs, and it failed without fail.  After reading this posting I used the following simple code to load my images, and it now works without fail;</p>
<p>NSString *fromName = [NSString stringWithFormat:@"image%d", i];<br />
NSString *fromPhotoName = [[NSBundle mainBundle] pathForResource:fromName ofType:@&#8221;jpg&#8221;];<br />
UIImage *fromPhoto = [UIImage imageWithContentsOfFile:fromPhotoName];</p>
<p>Thanks again,<br />
CPL</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paweł Kata</title>
		<link>http://www.alexcurylo.com/blog/2009/01/13/imagenamed-is-evil/comment-page-2/#comment-4438</link>
		<dc:creator>Paweł Kata</dc:creator>
		<pubDate>Mon, 24 Jan 2011 20:07:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.alexcurylo.com/blog/?p=386#comment-4438</guid>
		<description>Thanks for the article! I paired it with some NSCache mumbo-jumbo and my app finally manages memory properly! :D</description>
		<content:encoded><![CDATA[<p>Thanks for the article! I paired it with some NSCache mumbo-jumbo and my app finally manages memory properly! <img src='http://www.alexcurylo.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://www.alexcurylo.com/blog/2009/01/13/imagenamed-is-evil/comment-page-2/#comment-3613</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Thu, 26 Aug 2010 17:32:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.alexcurylo.com/blog/?p=386#comment-3613</guid>
		<description>1,000,000 THANKS !!!! Just that! 1,000,000 THANKS !!!! You saved me from going crazy with the stupid animation!

The only problem I have is that the animation goes really fast now. I put a wait() but it doesn&#039;t seem to work. I use a CATransition to switch between two views. Do you know if there is a way to make the animation run slower? I tried the CAtransition.duration but it doesn&#039;t work the right way. 

Again a 1,000,000 THANKS !!!!</description>
		<content:encoded><![CDATA[<p>1,000,000 THANKS !!!! Just that! 1,000,000 THANKS !!!! You saved me from going crazy with the stupid animation!</p>
<p>The only problem I have is that the animation goes really fast now. I put a wait() but it doesn&#8217;t seem to work. I use a CATransition to switch between two views. Do you know if there is a way to make the animation run slower? I tried the CAtransition.duration but it doesn&#8217;t work the right way. </p>
<p>Again a 1,000,000 THANKS !!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Alexander</title>
		<link>http://www.alexcurylo.com/blog/2009/01/13/imagenamed-is-evil/comment-page-2/#comment-3453</link>
		<dc:creator>Daniel Alexander</dc:creator>
		<pubDate>Tue, 20 Jul 2010 17:16:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.alexcurylo.com/blog/?p=386#comment-3453</guid>
		<description>Just one more note.  Although this is an issue with iOS4 on any iPhone, the problem is more dramatic using the new iPhone4.  Also, note that when I draw into the device context of an older iOS iPhone it is still faster than if I use layers on the same iPhone using iOS4.  So, it would be nice to still get that speed if I am using iOS with an older iPhone.  And the key is that sometimes you can.  It depends on the sizes and number of images that you are using.

So, for one of my Apps instead of using UIDevice to determine whether to use Layers or not use Layers depending on the iOS version number.  I decided I would get the actual device model using sysctlbyname.  Although UIDevice will also give you the model it does not distiguish between actual models of the iPhone.  Instead it just tells you it is an iPhone.  sysctlbyname will give you the additional information you need to distinguish between the different types of iPhones.

Here is my set of Defines for what sysctlbyname returns (It returns a string...I don&#039;t know if this forum is going to post this properly, but I will try anyway...all you really care about is the string literals):

[code]
#define DIDRST_Unknown @&quot;&quot; 
#define DIDRST_iPhoneSimulator @&quot;i386&quot;
#define DIDRST_iPhone1G @&quot;iPhone1,1&quot;
#define DIDRST_iPhone3G @&quot;iPhone1,2&quot;
#define DIDRST_iPhone3GS @&quot;iPhone2,1&quot;
#define DIDRST_iPhone4 @&quot;iPhone3,1&quot;
#define DIDRST_iPad1 @&quot;iPad,1&quot;
#define DIDRST_iPodTouch1G @&quot;iPod1,1&quot;
#define DIDRST_iPodTouch2G @&quot;iPod2,1&quot;
[/code]

So, now you can determine which devices you want to support with Layers and which you want to support with the older approach.  For instance, I wanted all the older devices to NOT use layers even though some of them may have been using iOS4.  This was only an issue for one of my apps.  On other apps I wanted any device using iOS4 to use Layers (in which case I used UIDevice instead of sysctlbyname).

Sadly I know someone out there in Internet World there is someone that will need this post (I sure was, but couldn&#039;t find anything).  Hope they find it here cause this thread is the extent of my helpfulness.  :)</description>
		<content:encoded><![CDATA[<p>Just one more note.  Although this is an issue with iOS4 on any iPhone, the problem is more dramatic using the new iPhone4.  Also, note that when I draw into the device context of an older iOS iPhone it is still faster than if I use layers on the same iPhone using iOS4.  So, it would be nice to still get that speed if I am using iOS with an older iPhone.  And the key is that sometimes you can.  It depends on the sizes and number of images that you are using.</p>
<p>So, for one of my Apps instead of using UIDevice to determine whether to use Layers or not use Layers depending on the iOS version number.  I decided I would get the actual device model using sysctlbyname.  Although UIDevice will also give you the model it does not distiguish between actual models of the iPhone.  Instead it just tells you it is an iPhone.  sysctlbyname will give you the additional information you need to distinguish between the different types of iPhones.</p>
<p>Here is my set of Defines for what sysctlbyname returns (It returns a string&#8230;I don&#8217;t know if this forum is going to post this properly, but I will try anyway&#8230;all you really care about is the string literals):</p>
<pre class="brush: plain; title: ; notranslate">
#define DIDRST_Unknown @""
#define DIDRST_iPhoneSimulator @"i386"
#define DIDRST_iPhone1G @"iPhone1,1"
#define DIDRST_iPhone3G @"iPhone1,2"
#define DIDRST_iPhone3GS @"iPhone2,1"
#define DIDRST_iPhone4 @"iPhone3,1"
#define DIDRST_iPad1 @"iPad,1"
#define DIDRST_iPodTouch1G @"iPod1,1"
#define DIDRST_iPodTouch2G @"iPod2,1"
</pre>
<p>So, now you can determine which devices you want to support with Layers and which you want to support with the older approach.  For instance, I wanted all the older devices to NOT use layers even though some of them may have been using iOS4.  This was only an issue for one of my apps.  On other apps I wanted any device using iOS4 to use Layers (in which case I used UIDevice instead of sysctlbyname).</p>
<p>Sadly I know someone out there in Internet World there is someone that will need this post (I sure was, but couldn&#8217;t find anything).  Hope they find it here cause this thread is the extent of my helpfulness.  <img src='http://www.alexcurylo.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Alexander</title>
		<link>http://www.alexcurylo.com/blog/2009/01/13/imagenamed-is-evil/comment-page-2/#comment-3451</link>
		<dc:creator>Daniel Alexander</dc:creator>
		<pubDate>Tue, 20 Jul 2010 17:01:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.alexcurylo.com/blog/?p=386#comment-3451</guid>
		<description>By the way, you might still want your app to support older iPhones (like the iPhone1, etc).  Those iPhones can&#039;t even run OS4.  You can use UIDevice to get the systemVersion.  If the systemVersion floatVal is greater than or equal to 4.0 then you could use Layers.  Otherwise, you would just keep doing what you used to do (drawing into a Rect most likely...or onto a device context of a UIView...or whatever was working with the older iOS).  So, just create a simply iVar bool called useLayers that you set up in your init (using UIDevice).  Also, add a subLayer (or multiple subLayers depending on how many animations you want to be doing) to your UIViews layer so you can update its contents for iOS4 iPhones.  Then in your drawRect drop an &quot;if&quot; statement to determine which way you want to draw your images (into Layers or the old way).

Remember this is only if you run into trouble with your animations.  If the images are small enough you might not see any substantial slowing and then you can just keep doing what you are doing.  But if you upgrade to OS4 and your animations start to crawl then this is how you can fix it.</description>
		<content:encoded><![CDATA[<p>By the way, you might still want your app to support older iPhones (like the iPhone1, etc).  Those iPhones can&#8217;t even run OS4.  You can use UIDevice to get the systemVersion.  If the systemVersion floatVal is greater than or equal to 4.0 then you could use Layers.  Otherwise, you would just keep doing what you used to do (drawing into a Rect most likely&#8230;or onto a device context of a UIView&#8230;or whatever was working with the older iOS).  So, just create a simply iVar bool called useLayers that you set up in your init (using UIDevice).  Also, add a subLayer (or multiple subLayers depending on how many animations you want to be doing) to your UIViews layer so you can update its contents for iOS4 iPhones.  Then in your drawRect drop an &#8220;if&#8221; statement to determine which way you want to draw your images (into Layers or the old way).</p>
<p>Remember this is only if you run into trouble with your animations.  If the images are small enough you might not see any substantial slowing and then you can just keep doing what you are doing.  But if you upgrade to OS4 and your animations start to crawl then this is how you can fix it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Alexander</title>
		<link>http://www.alexcurylo.com/blog/2009/01/13/imagenamed-is-evil/comment-page-2/#comment-3447</link>
		<dc:creator>Daniel Alexander</dc:creator>
		<pubDate>Tue, 20 Jul 2010 00:13:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.alexcurylo.com/blog/?p=386#comment-3447</guid>
		<description>Ok, so here is the issue as I can see.  The issue I mentioned earlier (with the iPhone 4) is actually an issue with OS4 (though it is a bit more problematic with iPhone 4).  Apparently the OS4 does not draw into a Rect, UIView, or into a device context as efficiently as the older OS&#039;s did (OS3.2-).  However, Apple did put effort into increasing the efficiency of Layers.  On the older OS&#039;s using Layers actually slowed things down for these types of image animations so drawing onto the device context was fastest.  However, with OS4 it is the other way around.  Using a sublayer contents to display images for this type of animation is now faster than drawing onto the context (which is now much slower).

Sooooooo, if your animations all of a sudden slow down to a crawl once you upgrade to OS4 then this is why that is happening.  You need to switch your animations over to using a sublayer and updating its contents.</description>
		<content:encoded><![CDATA[<p>Ok, so here is the issue as I can see.  The issue I mentioned earlier (with the iPhone 4) is actually an issue with OS4 (though it is a bit more problematic with iPhone 4).  Apparently the OS4 does not draw into a Rect, UIView, or into a device context as efficiently as the older OS&#8217;s did (OS3.2-).  However, Apple did put effort into increasing the efficiency of Layers.  On the older OS&#8217;s using Layers actually slowed things down for these types of image animations so drawing onto the device context was fastest.  However, with OS4 it is the other way around.  Using a sublayer contents to display images for this type of animation is now faster than drawing onto the context (which is now much slower).</p>
<p>Sooooooo, if your animations all of a sudden slow down to a crawl once you upgrade to OS4 then this is why that is happening.  You need to switch your animations over to using a sublayer and updating its contents.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Alexander</title>
		<link>http://www.alexcurylo.com/blog/2009/01/13/imagenamed-is-evil/comment-page-2/#comment-3436</link>
		<dc:creator>Daniel Alexander</dc:creator>
		<pubDate>Fri, 16 Jul 2010 19:00:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.alexcurylo.com/blog/?p=386#comment-3436</guid>
		<description>Its important to make note that &quot;small png&quot; can mean two different things.  It could mean that the file sizes are small 4kb, 10kb, 90kb?  But those file sizes have little effect on the problem you are running into (though there might be some indirect relationship, such can&#039;t be relied on).  What is important is the decoded image size.  You can encode an image into a small file size by doing all sorts of tricks like using a smaller color pallet (web colors, etc).  So, looking at the file sizes of the png&#039;s is not terrible helpful.  It is probably more helpful to consider the actual dimensions of your images.  Like if you have a 38kb png file that is a 300x300 image then the decoded image size will be a lot more (I&#039;ll guess around 300KB uncompressed).  It is the decoded images that need to fit into memory and it is the decoded images that will dictate how fast you can animate.

Mind you there is still good reason to get your png file sizes down.  There is a limit to the app size that can be downloaded through ATT&#039;s network.  I have found that people want to buy apps when they are sitting outside with friends or some such.  That means that if a user has a choice between waiting until they get home to buy your 11mb app and someone else&#039;s 9mb app that they can download emmediatly they will by the 9mb app (I think the limit is still 10mb, but they may have changed it to 20mb recently...but I don&#039;t think so...I think it is still 10mb).  So, smaller png files sizes can be helpful in that regard (there are lots of tricks you can do to bring that down considerably).  But those sizes don&#039;t matter when you are trying to animate.  Actually, they can hurt your animation speeds because there is more work decoding them.</description>
		<content:encoded><![CDATA[<p>Its important to make note that &#8220;small png&#8221; can mean two different things.  It could mean that the file sizes are small 4kb, 10kb, 90kb?  But those file sizes have little effect on the problem you are running into (though there might be some indirect relationship, such can&#8217;t be relied on).  What is important is the decoded image size.  You can encode an image into a small file size by doing all sorts of tricks like using a smaller color pallet (web colors, etc).  So, looking at the file sizes of the png&#8217;s is not terrible helpful.  It is probably more helpful to consider the actual dimensions of your images.  Like if you have a 38kb png file that is a 300&#215;300 image then the decoded image size will be a lot more (I&#8217;ll guess around 300KB uncompressed).  It is the decoded images that need to fit into memory and it is the decoded images that will dictate how fast you can animate.</p>
<p>Mind you there is still good reason to get your png file sizes down.  There is a limit to the app size that can be downloaded through ATT&#8217;s network.  I have found that people want to buy apps when they are sitting outside with friends or some such.  That means that if a user has a choice between waiting until they get home to buy your 11mb app and someone else&#8217;s 9mb app that they can download emmediatly they will by the 9mb app (I think the limit is still 10mb, but they may have changed it to 20mb recently&#8230;but I don&#8217;t think so&#8230;I think it is still 10mb).  So, smaller png files sizes can be helpful in that regard (there are lots of tricks you can do to bring that down considerably).  But those sizes don&#8217;t matter when you are trying to animate.  Actually, they can hurt your animation speeds because there is more work decoding them.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

