Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling ALAssetReprsentation's metadata method several hundred times will fail
    primarykey
    data
    text
    <p>I am writing a tiny iPhone app to retrieve metadata, such as EXIF info, for all photos stored in the iPhone, and ran into a weird issue when calling the Assets Library Framework API. Basically, if I am calling ALAssetReprsentation's metadata method (http://developer.apple.com/library/ios/documentation/AssetsLibrary/Reference/ALAssetRepresentation_Class/Reference/Reference.html#//apple_ref/occ/instm/ALAssetRepresentation/metadata) for several hundred times (even for the same ALAssetReprsentation object), the API will report an error and return null instead of photo's metadata.</p> <p>Here is the code to reproduce this issue:</p> <pre><code>ALAsset *photo = ... // fetch a photo asset via Assets Library Framework int i = 0; ALAssetRepresentation *representation = [photo defaultRepresentation]; NSDictionary *metadata; while (i&lt;600) { i++; metadata = [representation metadata]; NSLog(@"photo %d indexed %@", i, metadata); } </code></pre> <p>Here is the output for the code above. In the beginning of the output, everything is okay, but after 500+ times, the metadata API will report error like "ImageIO: CGImageSourceCreateWithData data parameter is nil".</p> <pre><code>... 2011-12-29 21:46:17.106 MyApp[685:707] photo 578 indexed { ColorModel = RGB; DPIHeight = 72; DPIWidth = 72; ... } ... ImageIO: &lt;ERROR&gt; CGImageSourceCreateWithData data parameter is nil 2011-12-29 21:46:17.151 MyApp[685:707] photo 579 indexed (null) ImageIO: &lt;ERROR&gt; CGImageSourceCreateWithData data parameter is nil 2011-12-29 21:46:17.177 MyApp[685:707] photo 580 indexed (null) </code></pre> <p>I am testing in an iPhone 3GS with iOS 5.0.1. And I am developing with Xcode 4.2 with ARC (automatical reference counting) enabled. And I can only reproduce this issue when deploying the app to the iPhone 3GS device, but cannot reproduce this issue when using iOS simulator with the same code (at least I don't reproduce this issue after calling the API over 1800 times in iOS simulator).</p> <p>Any help is appreciated. Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload