Hi, This sounds like a bug somewhere, can you file it here: http://bugzilla.xamarin.com with a complete test project we can use to reproduce this?
Thanks, Rolf On Tue, Jul 10, 2012 at 7:43 PM, Jim Crismale <[email protected]>wrote: > Is there a best practice code example demonstrating how to use the > ALAssetsLibrary, specifically with adding new asset groups and adding > photos to them? > > I've seen a few samples out there, but none of them seem to handle the > async nature of these methods properly and I am running into difficulty > with what should be an extremely simple task. > > In the code example below, 50% of the time the newly added group has one > or more null property values, preventing the image from being added to the > new group. According to Apple's docs, you are supposed to do "work" with > the object received in the block but I can't see how you can when it is in > an invalid state. > > I set up an observer to detect when the > "ALAssetsLibraryChangedNotification" gets fired to reload (as suggested on > SO) and determined that there were many times this notification did not get > fired between the time of the call and the addition of the new object which > was returned in an invalid state. > > I've tried re-enumerating after adding with sleep timers and pulling the > object out that way, but apparently it still wasn't "ready" with all of > it's property values yet. > > alibrary.AddAssetsGroupAlbum(albumName.ToString(),delegate(ALAssetsGroup > newGroup) { > try { > Helper.LogMessage("New Asset Group added, named: " + > newGroup.Name); > Helper.LogMessage("New Group type: " + newGroup.Type); > Helper.LogMessage("New Group ID: " + newGroup.PersistentID); > Helper.LogMessage("New Group URL: " + newGroup.PropertyUrl); > } catch (Exception) { > Helper.LogMessage("one or more properties of newly created > asset group is null."); > } > > alibrary.AssetForUrl(assetUrl, delegate(ALAsset asset) { > Helper.LogMessage("asset retrieved."); > newGroup.AddAsset(asset); > } , delegate(NSError assetError) { > Helper.LogMessage(assetError.ToString()); > } ); > > }, delegate (NSError errorFailVar) { > Helper.LogMessage(errorFailVar.ToString()); > } ); > > There has to be an easy way to do this. Appreciate any help! > ------------------------------ > View this message in context: ALAssetsLibrary - AddAssetsGroupAlbum Block > Returns Invalid ALAssetsGroup > Object<http://monotouch.2284126.n4.nabble.com/ALAssetsLibrary-AddAssetsGroupAlbum-Block-Returns-Invalid-ALAssetsGroup-Object-tp4655909.html> > Sent from the MonoTouch mailing list > archive<http://monotouch.2284126.n4.nabble.com/>at Nabble.com. > > _______________________________________________ > MonoTouch mailing list > [email protected] > http://lists.ximian.com/mailman/listinfo/monotouch > >
_______________________________________________ MonoTouch mailing list [email protected] http://lists.ximian.com/mailman/listinfo/monotouch
