Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Reload table view on image load

  • Loading branch information...
commit b648e33481d1fcbaff8bbfcd3d696aa8a0e706eb 1 parent ec2cee4
@mattt mattt authored
View
1  Example/AppDelegate.h
@@ -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
5 Example/AppDelegate.m
@@ -60,6 +60,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
@implementation AppDelegate
@synthesize window = _window;
+@synthesize tableView = _tableView;
@synthesize tweetsArrayController = _tweetsArrayController;
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
@@ -71,6 +72,10 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification {
[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
2  Example/Classes/Models/User.h
@@ -22,6 +22,8 @@
#import <Foundation/Foundation.h>
+extern NSString * const kUserProfileImageDidLoadNotification;
+
@interface User : NSObject
@property (readonly) NSUInteger userID;
View
4 Example/Classes/Models/User.m
@@ -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 @@ - (NSImage *)profileImage {
self.profileImage = image;
_profileImageRequestOperation = nil;
+
+ [[NSNotificationCenter defaultCenter] postNotificationName:kUserProfileImageDidLoadNotification object:self userInfo:nil];
}];
[_profileImageRequestOperation setCacheResponseBlock:^NSCachedURLResponse *(NSURLConnection *connection, NSCachedURLResponse *cachedResponse) {
View
2  Example/Mac-Info.plist
@@ -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
24 Example/MainMenu.xib
@@ -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"/>
@@ -757,6 +752,14 @@
<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>
<reference key="source" ref="553559566"/>
@@ -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,12 +2008,17 @@
<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>
</object>
@@ -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>
Please sign in to comment.
Something went wrong with that request. Please try again.