views:

361

answers:

1

Hi Coders,

I'm trying to create own UIImagePickerController using Assets Library Framework from the latest SDK 4.0. Here's the code:

-(void)viewDidLoad{

 [super viewDidLoad];

 groups = [[NSMutableArray alloc] init];
 ALAssetsLibrary *assetsLibrary = [[ALAssetsLibrary alloc] init];
 NSUInteger groupTypes = ALAssetsGroupAlbum;

 ALAssetsLibraryGroupsEnumerationResultsBlock listGroupBlock = ^(ALAssetsGroup *group, BOOL *stop) {
  if (group)
   [groups addObject:group];
 };

 ALAssetsLibraryAccessFailureBlock failureBlock = ^(NSError *error) {
  NSString *errorTitle = [error localizedDescription];
  NSString *errorMessage = [error localizedRecoverySuggestion];
  NSString *errorFailureDesc = [error localizedFailureReason];

  NSLog(@"Error: %@, Suggestion: %@, Failure desc: %@", errorTitle, errorMessage, errorFailureDesc); 
 };

 [assetsLibrary enumerateGroupsWithTypes:groupTypes usingBlock:listGroupBlock failureBlock:failureBlock];
}

The problem here is that I receive an error and the failure block is called from the gorups enumerator. Here's the log:

Error: Global denied access

Suggestion: This setting can be changed in Preferences.

Failure desc: The user has denied all applications access to their media.

As shown in the SDK 4.0 demonstrations there should be displayed a message that the application wants access to the photo albums and the user should grand access. I see no message at all and receive the error described above. Is there someone who can tell me what should be changed in the Preferences to solve the problem?

Thanks, Viktor.

+1  A: 

In order to access this information Location Serivices should be tunred ON!!! There is no need to reset all the settings. In this case the allow access dialog will appear.

Viktor