I have a problem with displaying image in my UIImageView.
So this is how I get images in ShareViewController:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
for (NSItemProvider* itemProvider in ((NSExtensionItem*)self.extensionContext.inputItems[0]).attachments )
{
if([itemProvider hasItemConformingToTypeIdentifier:#"public.image"])
{
++counter;
[itemProvider loadItemForTypeIdentifier:#"public.image" options:nil completionHandler:
^(id<NSSecureCoding> item, NSError *error)
{
UIImage *sharedImage = nil;
if([(NSObject*)item isKindOfClass:[NSURL class]])
{
sharedImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:(NSURL*)item]];
}
if([(NSObject*)item isKindOfClass:[UIImage class]])
{
sharedImage = (UIImage*)item;
}
if ([(NSObject *)item isKindOfClass:[NSData class]])
{
sharedImage = [UIImage imageWithData:(NSData *)item];
}
[[NSNotificationCenter defaultCenter] postNotificationName:#"kNotificationDidLoadItem" object:sharedImage];
}];
}
}
}
this is how I receive notification in DetailsViewController:
- (void)didLoadSharedImage:(NSNotification *)notification {
UIImage *sharedImage = [notification object];
[self.sharedImages addObject:sharedImage];
if (!self.theImageView.image) {
self.theImageView.image = sharedImage;
}
}
So there is no visible image after this method. I debugged it and I saw that image is there, but it's strange that I see it when I push new view controller form DetailsViewController and then pop back. Only then UIImageView seems like refresh its self.
Did you try to execute didLoadSharedImage into UIThread. like
dispatch_async(dispatch_get_main_queue(), ^{
if (!self.theImageView.image) {
self.theImageView.image = sharedImage;
}
})
Good luck
Related
I would like to know how to check if a value changed in another ViewController that is running in background. I have that code in that Viewcontroller that is downloading in background, and it puts me the isSyncAutoOnGoing to NO when the download is finished.
ViewController.m
#interface ViewController ()
{
BOOL isSyncAutoOnGoing;
}
- (void) sync:(id) sender
{
isSyncAutoOnGoing = YES;
dispatch_queue_t downloadQueue = dispatch_queue_create("downloader", NUL
L);
dispatch_async(downloadQueue, ^{
// do our long running process here
ListOfValueSync * lovSync = [[ListOfValueSync alloc] init];
// Synchronization
BOOL ret = [lovSync getAllListOfValueAll];
// do any UI stuff on the main UI thread
dispatch_async(dispatch_get_main_queue(), ^{
[spinner stopAnimating];
[spinner removeFromSuperview];
isSyncAutoOnGoing = NO;
NSLog(isSyncAutoOnGoing ? #"sync Yes" : #"sync No");
if ([sender isKindOfClass:[UIButton class]])
{
self.loginField.text = #"";
(!ret) ? [self alertStatus:#"Can not synchronize" :#"Sync Failed!" :0] : [self alertStatus:#"Synchronization OK" :#"Sync OK" :0];
[sender setEnabled:TRUE];
}
});
});
}
}
Here is the FormViewController where I want to check when the isSyncAutoOnGoing is equal to NO. I know it is not the good way I think, and more, the value of isSyncAutoOnGoing is always equal to YES.
FormViewController.m
NSArray *viewControllers = [[self navigationController] viewControllers];
id obj;
for (int i = 0; i < [viewControllers count]; i ++)
{
obj = [viewControllers objectAtIndex:i];
if ([obj isKindOfClass:NSClassFromString(#"ViewController")])
{
BOOL isSyncAutoOnGoing = [[obj valueForKey:#"isSyncAutoOnGoing"] boolValue];
if (isSyncAutoOnGoing)
{
do{
[NSThread sleepForTimeInterval:1.0];
NSLog([[obj valueForKey:#"isSyncAutoOnGoing"] boolValue] ? #"isSyncAuto: YES" : #"isSyncAuto: NO");
}while([[obj valueForKey:#"isSyncAutoOnGoing"] boolValue]);
}
}
}
Any ideas?
Thanks in advance.
Suppose the array is in AppDelegate
AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
self.allNewsItems = appDelegate.allNewsItems;
[appDelegate addObserver:self
forKeyPath:#"allNewsItems"
options:NSKeyValueObservingOptionNew
context:NULL];
and implement
- (void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary *)change context:(void *)context{
if ([keyPath isEqualToString:#"allNewsItems"]){ if ([self isBeingPresented]){
[self.tableView reloadData]; }else{
self.mustReloadView = YES;
}
} }
I am integrating MoPub SDK to mediate ADs from the Google AdMob network. I can get the AD to show after implementing my own customEvent and Adapter, but i can't get the AD to handle click events on its own. As in when I click on the AdMob native AD, it won't direct me anywhere. When using Facebook and Flurry's CustomEvent and Adapter, clicks are handled automatically. Anyone have any experience on this subject?
Thanks in Advance. Code below:
MPGoogleAdMobCustomEvent
#interface MPGoogleAdMobCustomEvent()
#property(nonatomic, strong)GADAdLoader *loader;
#end
#implementation MPGoogleAdMobCustomEvent
- (void)requestAdWithCustomEventInfo:(NSDictionary *)info
{
MPLogInfo(#"MOPUB: requesting AdMob Native Ad");
NSString *adUnitID = [info objectForKey:#"adUnitID"];
if (!adUnitID) {
[self.delegate nativeCustomEvent:self didFailToLoadAdWithError:MPNativeAdNSErrorForInvalidAdServerResponse(#"MOPUB: No AdUnitID from GoogleAdMob")];
return;
}
self.loader = [[GADAdLoader alloc] initWithAdUnitID:adUnitID rootViewController:nil adTypes:#[kGADAdLoaderAdTypeNativeContent] options:nil];
self.loader.delegate = self;
GADRequest *request = [GADRequest request];
#if (TARGET_OS_SIMULATOR)
request.testDevices = #[ kGADSimulatorID ];
#endif
CLLocation *location = [[CLLocationManager alloc] init].location;
if (location) {
[request setLocationWithLatitude:location.coordinate.latitude
longitude:location.coordinate.longitude
accuracy:location.horizontalAccuracy];
}
request.requestAgent = #"MoPub";
[self.loader loadRequest:request];
}
- (void)adLoader:(GADAdLoader *)adLoader didReceiveNativeContentAd:(GADNativeContentAd *)nativeContentAd
{
MPLogDebug(#"MOPUB: Did receive nativeAd");
MPGoogleAdMobNativeAdAdapter *adapter = [[MPGoogleAdMobNativeAdAdapter alloc] initWithGADNativeContentAd:nativeContentAd];
adapter.url = nativeContentAd.advertiser;
MPNativeAd *interfaceAd = [[MPNativeAd alloc] initWithAdAdapter:adapter];
NSMutableArray *imageArray = [NSMutableArray array];
for (GADNativeAdImage *images in nativeContentAd.images) {
[imageArray addObject:images.imageURL];
}
[super precacheImagesWithURLs:imageArray completionBlock:^(NSArray *errors) {
if ([errors count]) {
[self.delegate nativeCustomEvent:self didFailToLoadAdWithError:errors[0]];
} else {
[self.delegate nativeCustomEvent:self didLoadAd:interfaceAd];
}
}];
}
- (void)adLoader:(GADAdLoader *)adLoader didFailToReceiveAdWithError:(GADRequestError *)error
{
MPLogDebug(#"MOPUB: AdMob ad failed to load with error (customEvent): %#", error.description);
[self.delegate nativeCustomEvent:self didFailToLoadAdWithError:error];
}
#end
MPGoogleAdMobNativeAdAdapter
#interface MPGoogleAdMobNativeAdAdapter()<GADNativeAdDelegate>
#property(nonatomic, strong)NSDictionary *properties;
#end
#implementation MPGoogleAdMobNativeAdAdapter
- (instancetype)initWithGADNativeContentAd:(GADNativeContentAd *)contentAD
{
self = [super init];
if (self) {
self.contentAd = contentAD;
self.contentAd.delegate = self;
self.properties = [self convertAssetsToProperties:contentAD];
}
return self;
}
- (NSDictionary *)convertAssetsToProperties:(GADNativeContentAd *)adNative
{
self.contentAd = adNative;
NSMutableDictionary * dictionary = [NSMutableDictionary dictionary];
if (adNative.headline) {
dictionary[kAdTitleKey] = adNative.headline;
}
if (adNative.body) {
dictionary[kAdTextKey] = adNative.body;
}
if (adNative.images[0]) {
dictionary[kAdMainImageKey] = ((GADNativeAdImage *)adNative.images[0]).imageURL.absoluteString;
}
if (adNative.callToAction) {
dictionary[kAdCTATextKey] = adNative.callToAction;
}
return [dictionary copy];
}
#pragma mark MPNativeAdAdapter
- (NSTimeInterval)requiredSecondsForImpression
{
return 0.0;
}
- (NSURL *)defaultActionURL
{
return nil;
}
- (BOOL)enableThirdPartyClickTracking
{
return YES;
}
- (void)willAttachToView:(UIView *)view
{
self.contentAd.rootViewController = [self.delegate viewControllerForPresentingModalView];
}
- (void)didDetachFromView:(UIView *)view
{
self.contentAd.rootViewController = nil;
}
#pragma mark GADNativeAdDelegate
- (void)nativeAdWillPresentScreen:(GADNativeAd *)nativeAd
{
if ([self.delegate respondsToSelector:#selector(nativeAdWillPresentModalForAdapter:)]) {
[self.delegate nativeAdWillPresentModalForAdapter:self];
}
}
- (void)nativeAdDidDismissScreen:(GADNativeAd *)nativeAd
{
if ([self.delegate respondsToSelector:#selector(nativeAdDidDismissModalForAdapter:)]) {
[self.delegate nativeAdDidDismissModalForAdapter:self];
}
}
- (void)nativeAdWillLeaveApplication:(GADNativeAd *)nativeAd
{
if ([self.delegate respondsToSelector:#selector(nativeAdWillLeaveApplicationFromAdapter:)]) {
[self.delegate nativeAdWillLeaveApplicationFromAdapter:self];
}
}
#end
`
If you are having your custom UI for AdMob Ad's, then there will be a button which you will be using for callToAction part.
First of all you need to add a selector to detect action of click, to do add the selector for that button
[callToActionButton addTarget:self action:#selector(adCalled:) forControlEvents:UIControlEventTouchUpInside];
After that implement the adCalled method to get the click & call the method further, below is the code for your reference
Below is the example which I have used to get the ad object from my collection view & then I am redirecting it.
- (void)adCalled:(id)sender
{
CGPoint buttonPosition = [sender convertPoint:CGPointZero toView:mainCollectionView]; // Get the button position
NSIndexPath *indexPath = [collectionView indexPathForItemAtPoint:buttonPosition]; // Get the index path of button so that I can retrieve the correct ad object
id selectedAd = [adArray objectAtIndex:indexPath.row];
if ([selectedAd isKindOfClass:[GADNativeContentAd class]]) {
NSString *url = [selectedAd valueForKey:#"googleClickTrackingURLString"];
NSLog(#"URL is :%#", url);
NSURL *googleUrl = [NSURL URLWithString:url];
if ([[UIApplication sharedApplication] canOpenURL: googleUrl]) {
[[UIApplication sharedApplication] openURL:googleUrl];
}
}
}
Using this I can open the link n web using the google tracking url.
Hope this helps.
I have integrated the latest evernote ios sdk from github, That support both regular user and also business user. I can able to list the note book and notes without any issues but when i try to download the note attachment its giving me the following error.
Error Domain=ENErrorDomain Code=1 "Missing result: getResourceData
failed: unknown result" UserInfo=0x10dcb15f0
{NSLocalizedDescription=Missing result: getResourceData failed:
unknown result} Skipping field: due to type mismatch
(received:11)
Here the code i have used to download the note attachment.
+ (void)downloadDataWithNoteBook:(ENNotebook *)notebook fromNoteResource:(EDAMResource *)resource
onCompletion:(ZIdResultBlock)block {
ENPreferencesStore *preference = [ENSession sharedSession].preferences;
ENNoteStoreClient *noteStoreClient = [preference objectForKey:[SEEvernoteHelper getTitleForNoteAttachments:resource]];
NSString *str = resource.guid;
NSLog(#"GUID = [%#]", resource.guid);
[noteStoreClient getResourceDataWithGuid:resource.guid success:^(NSData *data) {
if(block) {
block(data, nil);
}
}
failure:^(NSError *error) {
if (block) {
block(nil, error);
}}];
}
Finally i was able to do it!!!
Here is my code:
//select the file that you want to download from evernote
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
isParentNoteBooks = false;
if ([SEEvernoteHelper isNoteBookInstance:[self.datasourceObjects objectAtIndex:indexPath.row]]) {
self.selectedNoteBook = [self.datasourceObjects objectAtIndex:indexPath.row];
[self fetchAttachmentsForNoteBook:[self.datasourceObjects objectAtIndex:indexPath.row]];
// set here if the notebook is business or not.
if ([SEEvernoteHelper isBussinessNoteBook:self.selectedNoteBook]) {
isCurrentNoteBookBusiness = YES;
}
else{
isCurrentNoteBookBusiness = NO;
}
} else {
self.selectedFileNameToDownload = [SEEvernoteHelper getTitleForNoteAttachments:[self.datasourceObjects objectAtIndex:indexPath.row]];
self.selectedResource = [self.datasourceObjects objectAtIndex:indexPath.row];
[self downloadNoteResultObject:self.selectedResource];
}
}
//start the download process
- (void)downloadNoteResultObject:(id)resultObject {
MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
HUD.labelText = kStrDownloadingLabel;
HUD.detailsLabelText = self.selectedFileNameToDownload;
__weak __typeof__(self) weakSelf = self;
[SEEvernoteHelper downloadDataWithNoteBook:self.selectedNoteBook fromNoteResource:resultObject onCompletion:^(id result, NSError *error) {
if (result) {
[NSThread syncOnMain:^{
//save the downloaded data....
[HUD hide:YES];
}];
} else {
[HUD hide:YES];
[NSThread syncOnMain:^{
//error
}];
}
}];
}
//get the download file
+ (void)downloadDataWithNoteBook:(ENNotebook *)notebook fromNoteResource:(EDAMResource *)resource onCompletion:(ZIdResultBlock)block {
ENNoteStoreClient *noteStoreClient = [[ENSession sharedSession] noteStoreForNotebook:notebook];
[noteStoreClient getResourceWithGuid:resource.guid withData:YES withRecognition:NO withAttributes:YES withAlternateDate:NO success:^(EDAMResource *resource) {
if(block) {
block(resource.data.body, nil);
}
} failure:^(NSError *error) {
NSLog(#"Error : %#",error);
if (block) {
block(nil, error);
}
}];
}
I want to use AVCaptureSession to capture images within my iOS App.
Based on the code from Apple's sample for AVCam https://developer.apple.com/library/ios/samplecode/AVCam/Introduction/Intro.html I tried to show a preview ImageView every time an image is captured.
// Capture a still image.
[[self stillImageOutput] captureStillImageAsynchronouslyFromConnection:[[self stillImageOutput] connectionWithMediaType:AVMediaTypeVideo] completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {
if (imageDataSampleBuffer)
{
NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
[self processImage:[UIImage imageWithData:imageData]];
}
}];
After capturing processImage is called
- (void) processImage:(UIImage *)image
{
[[self postButton] setEnabled:YES];
[[self postButton] setHidden:NO];
[[self cancelButton] setEnabled:YES];
[[self cancelButton] setHidden:NO];
_preview = [[UIImageView alloc] init];
[_preview setImage:image];
_preview.hidden = NO;
}
But the ImageView is still unchanged/empty when it is displayed.
Can someone help me along?
This code works for me
AVCaptureConnection *connection = [_currentOutput connectionWithMediaType:AVMediaTypeVideo];
[self _setOrientationForConnection:connection];
[_captureOutputPhoto captureStillImageAsynchronouslyFromConnection:connection completionHandler:
^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {
if (!imageDataSampleBuffer) {
DLog(#"failed to obtain image data sample buffer");
// return delegate error
return;
}
if (error) {
if ([_delegate respondsToSelector:#selector(vision:capturedPhoto:error:)]) {
[_delegate vision:self capturedPhoto:nil error:error];
}
return;
}
NSMutableDictionary *photoDict = [[NSMutableDictionary alloc] init];
NSDictionary *metadata = nil;
// add photo metadata (ie EXIF: Aperture, Brightness, Exposure, FocalLength, etc)
metadata = (__bridge NSDictionary *)CMCopyDictionaryOfAttachments(kCFAllocatorDefault, imageDataSampleBuffer, kCMAttachmentMode_ShouldPropagate);
if (metadata) {
[photoDict setObject:metadata forKey:PBJVisionPhotoMetadataKey];
CFRelease((__bridge CFTypeRef)(metadata));
} else {
DLog(#"failed to generate metadata for photo");
}
// add JPEG and image data
NSData *jpegData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
if (jpegData) {
// add JPEG
[photoDict setObject:jpegData forKey:PBJVisionPhotoJPEGKey];
// add image
UIImage *image = [self _uiimageFromJPEGData:jpegData];
if (image) {
[photoDict setObject:image forKey:PBJVisionPhotoImageKey];
} else {
DLog(#"failed to create image from JPEG");
// TODO: return delegate on error
}
// add thumbnail
UIImage *thumbnail = [self _thumbnailJPEGData:jpegData];
if (thumbnail) {
[photoDict setObject:thumbnail forKey:PBJVisionPhotoThumbnailKey];
} else {
DLog(#"failed to create a thumnbail");
// TODO: return delegate on error
}
} else {
DLog(#"failed to create jpeg still image data");
// TODO: return delegate on error
}
if ([_delegate respondsToSelector:#selector(vision:capturedPhoto:error:)]) {
[_delegate vision:self capturedPhoto:photoDict error:error];
}
// run a post shot focus
[self performSelector:#selector(_focus) withObject:nil afterDelay:0.5f];
}];
I bet that the trouble here is that completionHandler for captureStillImageAsynchronouslyFromConnection isn't being called on main thread. Try redispatching your call out to the main thread.
dispatch_async(dispatch_get_main_queue(), ^{
[self processImage:[UIImage imageWithData:imageData]];
});
I also notice that you're never adding _preview as a subview of anything.
I'm seeking a tutorial on how to cache images loaded from a url into cells of a uitableview.
I found an example here
http://www.ericd.net/2009/05/iphone-caching-images-in-memory.html#top
But the code is incomplete. I'm an objective c novice so I found it very difficult to fill in the missing pieces.
Here is a simple ImageCache implementation using NSCache. ImageCache is a singelton.
ImageCache.h
#import <Foundation/Foundation.h>
#interface ImageCache : NSObject
#property (nonatomic, retain) NSCache *imgCache;
#pragma mark - Methods
+ (ImageCache*)sharedImageCache;
//- (void) AddImage:(NSString *)imageURL: (UIImage *)image;
- (void) AddImage:(NSString *)imageURL withImage:(UIImage *)image;
- (UIImage*) GetImage:(NSString *)imageURL;
- (BOOL) DoesExist:(NSString *)imageURL;
#end
ImageCache.m
#import "ImageCache.h"
#implementation ImageCache
#synthesize imgCache;
#pragma mark - Methods
static ImageCache* sharedImageCache = nil;
+(ImageCache*)sharedImageCache
{
#synchronized([ImageCache class])
{
if (!sharedImageCache)
sharedImageCache= [[self alloc] init];
return sharedImageCache;
}
return nil;
}
+(id)alloc
{
#synchronized([ImageCache class])
{
NSAssert(sharedImageCache == nil, #"Attempted to allocate a second instance of a singleton.");
sharedImageCache = [super alloc];
return sharedImageCache;
}
return nil;
}
-(id)init
{
self = [super init];
if (self != nil)
{
imgCache = [[NSCache alloc] init];
}
return self;
}
// - (void) AddImage:(NSString *)imageURL: (UIImage *)image
- (void) AddImage:(NSString *)imageURL withImage:(UIImage *)image
{
[imgCache setObject:image forKey:imageURL];
}
- (NSString*) GetImage:(NSString *)imageURL
{
return [imgCache objectForKey:imageURL];
}
- (BOOL) DoesExist:(NSString *)imageURL
{
if ([imgCache objectForKey:imageURL] == nil)
{
return false;
}
return true;
}
#end
Example
UIImage *image;
// 1. Check the image cache to see if the image already exists. If so, then use it. If not, then download it.
if ([[ImageCache sharedImageCache] DoesExist:imgUrl] == true)
{
image = [[ImageCache sharedImageCache] GetImage:imgUrl];
}
else
{
NSData *imageData = [[NSData alloc] initWithContentsOfURL: [NSURL URLWithString: imgUrl]];
image = [[UIImage alloc] initWithData:imageData];
// Add the image to the cache
//[[ImageCache sharedImageCache] AddImage:imgUrl :image];
[[ImageCache sharedImageCache] AddImage:imgUrl withImage:image];
}
A nice working example was found here
http://ezekiel.vancouver.wsu.edu/~wayne/yellowjacket/YellowJacket.zip
You could also try using the awesome EgoImage library written by the sharp fellows at enormego to accomplish this. It is very simple to use, makes efficient use of cache behind the scenes and is ideally suited to meet your requirements.
Here's the github path for the library which includes a demo app.
I wrote this (with concepts and some code taken from Lane Roathe's excellent UIImageView+Cache category) for an app I've been working on. It uses the ASIHTTPRequest classes as well, which are great. This could definitely be improved.. for example, by allowing requests to be canceled if no longer needed, or by utilizing the notification userInfo to allow for more precise UI updating.. but it's working well for my purposes.
#implementation ImageFetcher
#define MAX_CACHED_IMAGES 20
static NSMutableDictionary* cache = nil;
+ (void)asyncImageFetch:(UIImage**)anImagePtr withURL:(NSURL*)aUrl {
if(!cache) {
cache = [[NSMutableDictionary dictionaryWithCapacity:MAX_CACHED_IMAGES] retain];
}
UIImage* newImage = [cache objectForKey:aUrl.description];
if(!newImage) { // cache miss - doh!
ASIHTTPRequest *imageRequest = [ASIHTTPRequest requestWithURL:aUrl];
imageRequest.userInfo = [NSDictionary dictionaryWithObject:[NSValue valueWithPointer:anImagePtr] forKey:#"imagePtr"];
imageRequest.delegate = self;
[imageRequest setDidFinishSelector:#selector(didReceiveImage:)];
[imageRequest setDidFailSelector:#selector(didNotReceiveImage:)];
[imageRequest startAsynchronous];
}
else { // cache hit - good!
*anImagePtr = [newImage retain];
}
}
+ (void)didReceiveImage:(ASIHTTPRequest *)request {
NSLog(#"Image data received.");
UIImage **anImagePtr = [(NSValue*)[request.userInfo objectForKey:#"imagePtr"] pointerValue];
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
UIImage *newImage = [[UIImage imageWithData:[request responseData]] retain];
if(!newImage) {
NSLog(#"UIImageView: LoadImage Failed");
}
else {
*anImagePtr = newImage;
// check to see if we should flush existing cached items before adding this new item
if( [cache count] >= MAX_CACHED_IMAGES)
[cache removeAllObjects];
[cache setValue:newImage forKey:[request url].description];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc postNotificationName: #"ImageDidLoad" object: self userInfo:request.userInfo];
}
[pool drain];
}
You call this code as follows:
[ImageFetcher asyncImageFetch:&icon withURL:url];
I'm also using notifications, for better or worse, to let any owners of the corresponding UIImage know when they should redisplay- in this case, it's in a tableView context:
- (void)viewDidLoad {
[super viewDidLoad];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:#selector(imageDidLoad:) name:#"ImageDidLoad" object:nil];
}
- (void)imageDidLoad:(NSNotification*)notif {
NSLog(#"Received icon load notification.");
// reload table view so that new image appears.. would be better if I could
// only reload the particular UIImageView that holds this image, oh well...
[self.tableView reloadData];
}
- (void)dealloc {
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc removeObserver:self];
// ...
}
You also might wanna check HJCache. It comes with a UIImageView compatible view class that does all the caching transparently and is suitable to be used in UITableViewCells where scrolling performance is important.