Permalink
Browse files

Updated the sample app with the profile picture

  • Loading branch information...
1 parent 6e2b8dc commit 9da8108c3b4b0ffb96d27add1881555b1c88af07 @vytis vytis committed Jun 2, 2011
Showing with 694 additions and 63 deletions.
  1. +1 −0 .gitignore
  2. +3 −0 sample/FacebookTestAppDelegate.h
  3. +12 −2 sample/FacebookTestAppDelegate.m
  4. +678 −61 sample/en.lproj/MainMenu.xib
View
@@ -0,0 +1 @@
+sample/ApplicationID.h
@@ -17,14 +17,17 @@
NSTextField *request_label;
NSTextField *request_text;
NSTextView *result_text;
+ NSImageView *profile_picture;
NSButton *send_request;
NSWindow *window;
+
}
@property (assign) IBOutlet NSTextField *token_label;
@property (assign) IBOutlet NSTextField *request_label;
@property (assign) IBOutlet NSTextField *request_text;
@property (assign) IBOutlet NSTextView *result_text;
+@property (assign) IBOutlet NSImageView *profile_picture;
@property (assign) IBOutlet NSButton *send_request;
@property (assign) IBOutlet NSWindow *window;
@@ -15,6 +15,7 @@ @implementation FacebookTestAppDelegate
@synthesize request_label;
@synthesize request_text;
@synthesize result_text;
+@synthesize profile_picture;
@synthesize send_request;
@synthesize window;
@@ -54,6 +55,7 @@ - (void) tokenResult: (NSDictionary*) result
[self.request_text setEnabled: YES];
[self.send_request setEnabled: YES];
[self.result_text setEditable: YES];
+ [fb sendRequest:@"me/picture"];
}
else
{
@@ -64,9 +66,17 @@ - (void) tokenResult: (NSDictionary*) result
- (void) requestResult: (NSDictionary*) result
{
- [self.send_request setEnabled: YES];
+ if([[result objectForKey:@"request"] isEqualTo:@"me/picture"])
+ {
+ NSImage *pic = [[NSImage alloc] initWithData:[result objectForKey:@"raw"]];
+ self.profile_picture.image = pic;
+ [pic release];
+
+ } else {
+ [self.send_request setEnabled: YES];
+ [self.result_text setString: [NSString stringWithFormat: @"Request: {%@}\n%@", [result objectForKey: @"request"], [result objectForKey: @"result"]]];
+ }
- [self.result_text setString: [NSString stringWithFormat: @"Request: {%@}\n%@", [result objectForKey: @"request"], [result objectForKey: @"result"]]];
}
- (void) willShowUINotification: (PhFacebook*) sender
Oops, something went wrong.

0 comments on commit 9da8108

Please sign in to comment.