/iPhoneSample/Classes/TreeViewController.m

http://fskit.googlecode.com/ · Objective C · 96 lines · 45 code · 18 blank · 33 comment · 2 complexity · 5206edbc2f8e50ce201b0311eca49e01 MD5 · raw file

  1. //
  2. // TreeViewController.m
  3. // iPhoneSample
  4. //
  5. // Created by Logan Allred on 3/2/09.
  6. // Copyright 2009 RedBugz Software. All rights reserved.
  7. //
  8. #import "TreeViewController.h"
  9. #import <FSKit/FSKit.h>
  10. #import "TreeView.h"
  11. @implementation TreeViewController
  12. /*
  13. // The designated initializer. Override to perform setup that is required before the view is loaded.
  14. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
  15. if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
  16. // Custom initialization
  17. }
  18. return self;
  19. }
  20. */
  21. /*
  22. // Implement loadView to create a view hierarchy programmatically, without using a nib.
  23. - (void)loadView {
  24. }
  25. */
  26. // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
  27. - (void)viewDidLoad {
  28. [super viewDidLoad];
  29. // Make a request
  30. // FSKIdentityService *identityService = [[FSKIdentityService identityServiceWithConnection:connection delegate:self] retain];
  31. // [identityService loginWithCredential:[NSURLCredential credentialWithUser:@"api-user-1009" password:@"f8cc" persistence:NSURLCredentialPersistenceForSession]];
  32. FSKPersonService *personService = [[FSKPersonService
  33. personServiceWithConnection:[FSKConnection sharedConnection]
  34. delegate:self] retain];
  35. [personService readPerson:@""];
  36. // [FSKPersonSearchRequest
  37. // fetchSearchResultsWithCriteria:nil connection:connection
  38. // delegate:self
  39. // selector:@selector(request:didReturnResponse:)];
  40. //Handle the response by overriding these 2 methods in your delegate
  41. }
  42. - (void)request:(FSKRequest *)request
  43. didReturnResponse:(FSKResponse *)response
  44. {
  45. NSLog(@"%s", _cmd);
  46. if ([response isKindOfClass:[FSKPersonResponse class]])
  47. {
  48. FSKPersonResponse *resp = (FSKPersonResponse *)response;
  49. [self setPerson:[resp person]];
  50. }
  51. }
  52. - (void)request:(FSKRequest *)request
  53. didFailWithError:(FSKError *)error
  54. {
  55. NSLog(@"%s", _cmd);
  56. }
  57. - (void)setPerson:(FSKPerson *)person
  58. {
  59. if ([person personId]) {
  60. personIdLabel.text = [person personId];
  61. }
  62. nameLabel.text = [person fullName];
  63. // birthLabel.text = [[resp summary] birthdate];
  64. [treeView setRootPerson:person];
  65. [treeView setNeedsDisplay];
  66. }
  67. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  68. // Return YES for supported orientations
  69. return YES;//(interfaceOrientation == UIInterfaceOrientationPortrait);
  70. }
  71. - (void)didReceiveMemoryWarning {
  72. [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
  73. // Release anything that's not essential, such as cached data
  74. }
  75. - (void)dealloc {
  76. [super dealloc];
  77. }
  78. @end