Get device Photos

-(void)readImages:(int)getAlbumImages
{

    imagesArray = [[NSMutableArray alloc]init];
    allImagesArray = [[NSMutableArray alloc] init];

    ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
    void (^assetEnumerator)( ALAsset *, NSUInteger, BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop) {
        if(result != nil) {
             if([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypePhoto]) {
                        [allImagesArray addObject:[result valueForProperty:ALAssetPropertyURLs]];

                        NSURL *url= (NSURL*) [[result defaultRepresentation]url];
                        [library assetForURL:url
                                 resultBlock:^(ALAsset *asset) {
                                     [imagesArray addObject:[UIImage imageWithCGImage:[[asset defaultRepresentation] fullScreenImage]]];
                                     [picsTbl reloadData];
                                     [loadingView setHidden:YES];
                                 }
                                failureBlock:^(NSError *error){ NSLog(@"test:Fail"); } ];
                    }

                }
                else if(result == NULL){
                    [loadingView setHidden:YES];
                }
            };

            NSMutableArray *assetGroups = [[NSMutableArray alloc] init];
            void (^ assetGroupEnumerator) ( ALAssetsGroup *, BOOL *)= ^(ALAssetsGroup *group, BOOL *stop) {
                if(group != nil) {
                    [group enumerateAssetsUsingBlock:assetEnumerator];
                    [assetGroups addObject:group];
                    NSLog(@"Number of assets in group :%ld",(long)[group numberOfAssets]);
                    NSLog(@"asset group is:%@",assetGroups);
                }
                NSLog(@"[group numberOfAssets] %d",[group numberOfAssets]);

            };

            assetGroups = [[NSMutableArray alloc] init];

            [library enumerateGroupsWithTypes:ALAssetsGroupAll
                                   usingBlock:assetGroupEnumerator
                                 failureBlock:^(NSError *error) {NSLog(@"A problem occurred");}];
        }
http://stackoverflow.com/questions/11600621/iphone-twitter-api-get-users-followers-following

Comments

Popular posts from this blog

iOS Architecture

Performance Tips for IOS Application

setNeedsLayout vs layoutIfNeeded Explained