Reload table view on image load

This commit is contained in:
Mattt Thompson 2012-06-19 14:40:11 -07:00
parent ec2cee42d2
commit b648e33481
6 changed files with 29 additions and 9 deletions

View file

@ -42,6 +42,7 @@
@interface AppDelegate : NSObject <NSApplicationDelegate>
@property (strong) IBOutlet NSWindow *window;
@property (weak) IBOutlet NSTableView *tableView;
@property (strong) IBOutlet NSArrayController *tweetsArrayController;
@end

View file

@ -60,6 +60,7 @@
@implementation AppDelegate
@synthesize window = _window;
@synthesize tableView = _tableView;
@synthesize tweetsArrayController = _tweetsArrayController;
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
@ -71,6 +72,10 @@
[Tweet publicTimelineTweetsWithBlock:^(NSArray *tweets) {
self.tweetsArrayController.content = tweets;
}];
[[NSNotificationCenter defaultCenter] addObserverForName:kUserProfileImageDidLoadNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) {
[self.tableView reloadData];
}];
}
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag {

View file

@ -22,6 +22,8 @@
#import <Foundation/Foundation.h>
extern NSString * const kUserProfileImageDidLoadNotification;
@interface User : NSObject
@property (readonly) NSUInteger userID;

View file

@ -23,6 +23,8 @@
#import "User.h"
#import "AFImageRequestOperation.h"
NSString * const kUserProfileImageDidLoadNotification = @"com.alamofire.user.profile-image.loaded";
@interface User ()
+ (NSOperationQueue *)sharedProfileImageRequestOperationQueue;
@end
@ -74,6 +76,8 @@
self.profileImage = image;
_profileImageRequestOperation = nil;
[[NSNotificationCenter defaultCenter] postNotificationName:kUserProfileImageDidLoadNotification object:self userInfo:nil];
}];
[_profileImageRequestOperation setCacheResponseBlock:^NSCachedURLResponse *(NSURLConnection *connection, NSCachedURLResponse *cachedResponse) {

View file

@ -25,7 +25,7 @@
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2012年 __MyCompanyName__. All rights reserved.</string>
<string>Copyright © 2012年 Mattt Thompson. All rights reserved.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>

View file

@ -456,10 +456,6 @@
<object class="NSImageCell" key="NSDataCell" id="717955434">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">33554432</int>
<object class="NSCustomResource" key="NSContents">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">placeholder-stamp</string>
</object>
<object class="NSFont" key="NSSupport">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">13</double>
@ -539,7 +535,6 @@
<string key="NSFrame">{{1, 484}, {373, 15}}</string>
<reference key="NSSuperview" ref="905625827"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:1216</string>
<int key="NSsFlags">1</int>
<reference key="NSTarget" ref="905625827"/>
@ -756,6 +751,14 @@
</object>
<int key="connectionID">609</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">tableView</string>
<reference key="source" ref="976324537"/>
<reference key="destination" ref="256434433"/>
</object>
<int key="connectionID">848</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">value: arrangedObjects</string>
@ -1978,7 +1981,7 @@
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
<int key="maxID">847</int>
<int key="maxID">848</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@ -1990,11 +1993,13 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>tableView</string>
<string>tweetsArrayController</string>
<string>window</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSTableView</string>
<string>NSArrayController</string>
<string>NSWindow</string>
</object>
@ -2003,11 +2008,16 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>tableView</string>
<string>tweetsArrayController</string>
<string>window</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBToOneOutletInfo">
<string key="name">tableView</string>
<string key="candidateClassName">NSTableView</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">tweetsArrayController</string>
<string key="candidateClassName">NSArrayController</string>
@ -2047,13 +2057,11 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSMenuCheckmark</string>
<string>NSMenuMixedState</string>
<string>placeholder-stamp</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>{11, 11}</string>
<string>{10, 3}</string>
<string>{50, 50}</string>
</object>
</object>
<bool key="IBDocument.UseAutolayout">YES</bool>