Browse Source

Reload table view on image load

Mattt Thompson 13 years ago
parent
commit
b648e33481

+ 1 - 0
Example/AppDelegate.h

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

+ 5 - 0
Example/AppDelegate.m

@@ -60,6 +60,7 @@
 @implementation AppDelegate
 @implementation AppDelegate
 
 
 @synthesize window = _window;
 @synthesize window = _window;
+@synthesize tableView = _tableView;
 @synthesize tweetsArrayController = _tweetsArrayController;
 @synthesize tweetsArrayController = _tweetsArrayController;
 
 
 - (void)applicationDidFinishLaunching:(NSNotification *)notification {
 - (void)applicationDidFinishLaunching:(NSNotification *)notification {
@@ -71,6 +72,10 @@
     [Tweet publicTimelineTweetsWithBlock:^(NSArray *tweets) {
     [Tweet publicTimelineTweetsWithBlock:^(NSArray *tweets) {
         self.tweetsArrayController.content = 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 {
 - (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag {

+ 2 - 0
Example/Classes/Models/User.h

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

+ 4 - 0
Example/Classes/Models/User.m

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

+ 1 - 1
Example/Mac-Info.plist

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

+ 16 - 8
Example/MainMenu.xib

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