Skip to content

Commit b648e33

Browse files
committed
Reload table view on image load
1 parent ec2cee4 commit b648e33

6 files changed

Lines changed: 29 additions & 9 deletions

File tree

Example/AppDelegate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
@interface AppDelegate : NSObject <NSApplicationDelegate>
4343

4444
@property (strong) IBOutlet NSWindow *window;
45+
@property (weak) IBOutlet NSTableView *tableView;
4546
@property (strong) IBOutlet NSArrayController *tweetsArrayController;
4647

4748
@end

Example/AppDelegate.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
6060
@implementation AppDelegate
6161

6262
@synthesize window = _window;
63+
@synthesize tableView = _tableView;
6364
@synthesize tweetsArrayController = _tweetsArrayController;
6465

6566
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
@@ -71,6 +72,10 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification {
7172
[Tweet publicTimelineTweetsWithBlock:^(NSArray *tweets) {
7273
self.tweetsArrayController.content = tweets;
7374
}];
75+
76+
[[NSNotificationCenter defaultCenter] addObserverForName:kUserProfileImageDidLoadNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) {
77+
[self.tableView reloadData];
78+
}];
7479
}
7580

7681
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag {

Example/Classes/Models/User.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
#import <Foundation/Foundation.h>
2424

25+
extern NSString * const kUserProfileImageDidLoadNotification;
26+
2527
@interface User : NSObject
2628

2729
@property (readonly) NSUInteger userID;

Example/Classes/Models/User.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#import "User.h"
2424
#import "AFImageRequestOperation.h"
2525

26+
NSString * const kUserProfileImageDidLoadNotification = @"com.alamofire.user.profile-image.loaded";
27+
2628
@interface User ()
2729
+ (NSOperationQueue *)sharedProfileImageRequestOperationQueue;
2830
@end
@@ -74,6 +76,8 @@ - (NSImage *)profileImage {
7476
self.profileImage = image;
7577

7678
_profileImageRequestOperation = nil;
79+
80+
[[NSNotificationCenter defaultCenter] postNotificationName:kUserProfileImageDidLoadNotification object:self userInfo:nil];
7781
}];
7882

7983
[_profileImageRequestOperation setCacheResponseBlock:^NSCachedURLResponse *(NSURLConnection *connection, NSCachedURLResponse *cachedResponse) {

Example/Mac-Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<key>LSMinimumSystemVersion</key>
2626
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
2727
<key>NSHumanReadableCopyright</key>
28-
<string>Copyright © 2012年 __MyCompanyName__. All rights reserved.</string>
28+
<string>Copyright © 2012年 Mattt Thompson. All rights reserved.</string>
2929
<key>NSMainNibFile</key>
3030
<string>MainMenu</string>
3131
<key>NSPrincipalClass</key>

Example/MainMenu.xib

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,6 @@
456456
<object class="NSImageCell" key="NSDataCell" id="717955434">
457457
<int key="NSCellFlags">67239424</int>
458458
<int key="NSCellFlags2">33554432</int>
459-
<object class="NSCustomResource" key="NSContents">
460-
<string key="NSClassName">NSImage</string>
461-
<string key="NSResourceName">placeholder-stamp</string>
462-
</object>
463459
<object class="NSFont" key="NSSupport">
464460
<string key="NSName">LucidaGrande</string>
465461
<double key="NSSize">13</double>
@@ -539,7 +535,6 @@
539535
<string key="NSFrame">{{1, 484}, {373, 15}}</string>
540536
<reference key="NSSuperview" ref="905625827"/>
541537
<reference key="NSWindow"/>
542-
<reference key="NSNextKeyView"/>
543538
<string key="NSReuseIdentifierKey">_NS:1216</string>
544539
<int key="NSsFlags">1</int>
545540
<reference key="NSTarget" ref="905625827"/>
@@ -756,6 +751,14 @@
756751
</object>
757752
<int key="connectionID">609</int>
758753
</object>
754+
<object class="IBConnectionRecord">
755+
<object class="IBOutletConnection" key="connection">
756+
<string key="label">tableView</string>
757+
<reference key="source" ref="976324537"/>
758+
<reference key="destination" ref="256434433"/>
759+
</object>
760+
<int key="connectionID">848</int>
761+
</object>
759762
<object class="IBConnectionRecord">
760763
<object class="IBBindingConnection" key="connection">
761764
<string key="label">value: arrangedObjects</string>
@@ -1978,7 +1981,7 @@
19781981
<reference key="dict.values" ref="0"/>
19791982
</object>
19801983
<nil key="sourceID"/>
1981-
<int key="maxID">847</int>
1984+
<int key="maxID">848</int>
19821985
</object>
19831986
<object class="IBClassDescriber" key="IBDocument.Classes">
19841987
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -1990,11 +1993,13 @@
19901993
<bool key="EncodedWithXMLCoder">YES</bool>
19911994
<object class="NSArray" key="dict.sortedKeys">
19921995
<bool key="EncodedWithXMLCoder">YES</bool>
1996+
<string>tableView</string>
19931997
<string>tweetsArrayController</string>
19941998
<string>window</string>
19951999
</object>
19962000
<object class="NSArray" key="dict.values">
19972001
<bool key="EncodedWithXMLCoder">YES</bool>
2002+
<string>NSTableView</string>
19982003
<string>NSArrayController</string>
19992004
<string>NSWindow</string>
20002005
</object>
@@ -2003,11 +2008,16 @@
20032008
<bool key="EncodedWithXMLCoder">YES</bool>
20042009
<object class="NSArray" key="dict.sortedKeys">
20052010
<bool key="EncodedWithXMLCoder">YES</bool>
2011+
<string>tableView</string>
20062012
<string>tweetsArrayController</string>
20072013
<string>window</string>
20082014
</object>
20092015
<object class="NSArray" key="dict.values">
20102016
<bool key="EncodedWithXMLCoder">YES</bool>
2017+
<object class="IBToOneOutletInfo">
2018+
<string key="name">tableView</string>
2019+
<string key="candidateClassName">NSTableView</string>
2020+
</object>
20112021
<object class="IBToOneOutletInfo">
20122022
<string key="name">tweetsArrayController</string>
20132023
<string key="candidateClassName">NSArrayController</string>
@@ -2047,13 +2057,11 @@
20472057
<bool key="EncodedWithXMLCoder">YES</bool>
20482058
<string>NSMenuCheckmark</string>
20492059
<string>NSMenuMixedState</string>
2050-
<string>placeholder-stamp</string>
20512060
</object>
20522061
<object class="NSArray" key="dict.values">
20532062
<bool key="EncodedWithXMLCoder">YES</bool>
20542063
<string>{11, 11}</string>
20552064
<string>{10, 3}</string>
2056-
<string>{50, 50}</string>
20572065
</object>
20582066
</object>
20592067
<bool key="IBDocument.UseAutolayout">YES</bool>

0 commit comments

Comments
 (0)