Ser Pounce
Ser Pounce

Reputation: 14571

ALAssetsLibraryChangedNotification not being triggered in ios5?

I had implemented the ALAssetsLibraryChangedNotification in ios4 and it worked perfectly, however now in ios5 it seems it's getting ignored. I add:

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ALAssetsLibraryChangedNotification) name: ALAssetsLibraryChangedNotification object:self.library]; 

in my view controller initializer and in dealloc I put:

[[NSNotificationCenter defaultCenter] removeObserver:self name:ALAssetsLibraryChangedNotification object:nil];

Then the methdod implementation itself is:

- (void) ALAssetsLibraryChangedNotification
{
//doSomeStuff

}

I need to add it in the initializer and remove it in dealloc so it updates if the user changes the library while out of the app. Anyone know a good solution to this?

Upvotes: 0

Views: 2683

Answers (1)

arturgrigor
arturgrigor

Reputation: 9451

I think that he meant to say:

  1. Call [self.assetsLibrary writeImageToSavedPhotosAlbum:nil metadata:nil completionBlock:^(NSURL *assetURL, NSError *error) { }]; immediately after creating instance of ALAssetsLibrary
  2. Observe ALAssetsLibraryChangedNotification (not NSManagedObjectContextObjectsDidChangeNotification)

Upvotes: 4

Related Questions