i have the following code which print the url of updated image
override func viewWillAppear(animated: Bool) {
NSNotificationCenter.defaultCenter().addObserver(self, selector: "assetChange:", name: ALAssetsLibraryChangedNotification, object: nil) }
func assetChange(notification: NSNotification){
if var info:NSDictionary = notification.userInfo { var url:NSSet = info.objectForKey(ALAssetLibraryUpdatedAssetsKey) as NSSet
var aurl:NSURL = url.anyObject() as NSURL
println(aurl)
}
}
this code work fine but it will print only first modified image url,but i want all the list of modified image url(array of modified images) please help me
You're choosing one object from the set when using url.anyObject()
. Instead you need to get all objects from the set and then iterate through the array. The following code should help you:
func assetChange(notification: NSNotification) {
if var info:NSDictionary = notification.userInfo { var url:NSSet = info.objectForKey(ALAssetLibraryUpdatedAssetsKey) as NSSet
var urls: [NSURL] = url.allObjects as [NSURL]
for singleUrl in urls {
println(singleUrl)
}
}
}