문제

I'm using a block for completion handler. How to access a imageView/UIElements inside a block,

     [storyImageView setImageWithURL:[NSURL URLWithString:imageURL] placeholderImage:Nil completed:^(UIImage *storyImage,NSError *error,SDImageCacheType cacheType)
   {
       //need to access storyImageView inside a block
   }];
도움이 되었습니까?

해결책

look at this question Get UIImageView using Afnetworking and put it in an array

as i understand you are using Afnetworking category for setting uiimages.

Your image will be automaticaly set. look at the method "setImage..."

Blocks here for example to reload table data.

If you need to update ui/ access ui elements you need to do it in main thread

dispatch_async(dispatch_get_main_queue(), ^{
    //updates
});

if you have some instances (no matter UI or not) and you want access them in block you should add "__block" before it.

e.g.

__block NSString *myString = @"test";
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top