FBFriendPickerViewController.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. * Copyright 2010-present Facebook.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <UIKit/UIKit.h>
  17. #import "FBCacheDescriptor.h"
  18. #import "FBGraphUser.h"
  19. #import "FBPeoplePickerViewController.h"
  20. @protocol FBFriendPickerDelegate;
  21. /*!
  22. @class
  23. @abstract
  24. The `FBFriendPickerViewController` class creates a controller object that manages
  25. the user interface for displaying and selecting Facebook friends.
  26. @discussion
  27. When the `FBFriendPickerViewController` view loads it creates a `UITableView` object
  28. where the friends will be displayed. You can access this view through the `tableView`
  29. property. The friend display can be sorted by first name or last name. Friends'
  30. names can be displayed with the first name first or the last name first.
  31. The friend data can be pre-fetched and cached prior to using the view controller. The
  32. cache is setup using an <FBCacheDescriptor> object that can trigger the
  33. data fetch. Any friend data requests will first check the cache and use that data.
  34. If the friend picker is being displayed cached data will initially be shown before
  35. a fresh copy is retrieved.
  36. The `delegate` property may be set to an object that conforms to the <FBFriendPickerDelegate>
  37. protocol. The `delegate` object will receive updates related to friend selection and
  38. data changes. The delegate can also be used to filter the friends to display in the
  39. picker.
  40. */
  41. @interface FBFriendPickerViewController : FBPeoplePickerViewController
  42. /*!
  43. @abstract
  44. The list of friends that are currently selected in the veiw.
  45. The items in the array are <FBGraphUser> objects.
  46. @discussion
  47. You can set this this array to pre-select items in the picker. The objects in the array
  48. must be complete id<FBGraphUser> objects (i.e., fetched from a Graph query or from a
  49. previous picker's selection, with id and appropriate name fields).
  50. */
  51. @property (nonatomic, copy, readwrite) NSArray *selection;
  52. /*!
  53. @abstract
  54. Configures the properties used in the caching data queries.
  55. @discussion
  56. Cache descriptors are used to fetch and cache the data used by the view controller.
  57. If the view controller finds a cached copy of the data, it will
  58. first display the cached content then fetch a fresh copy from the server.
  59. @param cacheDescriptor The <FBCacheDescriptor> containing the cache query properties.
  60. */
  61. - (void)configureUsingCachedDescriptor:(FBCacheDescriptor *)cacheDescriptor;
  62. /*!
  63. @method
  64. @abstract
  65. Creates a cache descriptor based on default settings of the `FBFriendPickerViewController` object.
  66. @discussion
  67. An `FBCacheDescriptor` object may be used to pre-fetch data before it is used by
  68. the view controller. It may also be used to configure the `FBFriendPickerViewController`
  69. object.
  70. */
  71. + (FBCacheDescriptor *)cacheDescriptor;
  72. /*!
  73. @method
  74. @abstract
  75. Creates a cache descriptor with additional fields and a profile ID for use with the `FBFriendPickerViewController` object.
  76. @discussion
  77. An `FBCacheDescriptor` object may be used to pre-fetch data before it is used by
  78. the view controller. It may also be used to configure the `FBFriendPickerViewController`
  79. object.
  80. @param userID The profile ID of the user whose friends will be displayed. A nil value implies a "me" alias.
  81. @param fieldsForRequest The set of additional fields to include in the request for friend data.
  82. */
  83. + (FBCacheDescriptor *)cacheDescriptorWithUserID:(NSString *)userID fieldsForRequest:(NSSet *)fieldsForRequest;
  84. @end
  85. /*!
  86. @protocol
  87. @abstract
  88. The `FBFriendPickerDelegate` protocol defines the methods used to receive event
  89. notifications and allow for deeper control of the <FBFriendPickerViewController>
  90. view.
  91. The methods of <FBFriendPickerDelegate> correspond to <FBGraphObjectPickerDelegate>.
  92. If a pair of corresponding methods are implemented, the <FBGraphObjectPickerDelegate>
  93. method is called first.
  94. */
  95. @protocol FBFriendPickerDelegate <FBGraphObjectPickerDelegate>
  96. @optional
  97. /*!
  98. @abstract
  99. Tells the delegate that data has been loaded.
  100. @discussion
  101. The <FBFriendPickerViewController> object's `tableView` property is automatically
  102. reloaded when this happens. However, if another table view, for example the
  103. `UISearchBar` is showing data, then it may also need to be reloaded.
  104. @param friendPicker The friend picker view controller whose data changed.
  105. */
  106. - (void)friendPickerViewControllerDataDidChange:(FBFriendPickerViewController *)friendPicker;
  107. /*!
  108. @abstract
  109. Tells the delegate that the selection has changed.
  110. @param friendPicker The friend picker view controller whose selection changed.
  111. */
  112. - (void)friendPickerViewControllerSelectionDidChange:(FBFriendPickerViewController *)friendPicker;
  113. /*!
  114. @abstract
  115. Asks the delegate whether to include a friend in the list.
  116. @discussion
  117. This can be used to implement a search bar that filters the friend list.
  118. If -[<FBGraphObjectPickerDelegate> graphObjectPickerViewController:shouldIncludeGraphObject:]
  119. is implemented and returns NO, this method is not called.
  120. @param friendPicker The friend picker view controller that is requesting this information.
  121. @param user An <FBGraphUser> object representing the friend.
  122. */
  123. - (BOOL)friendPickerViewController:(FBFriendPickerViewController *)friendPicker
  124. shouldIncludeUser:(id<FBGraphUser>)user;
  125. /*!
  126. @abstract
  127. Tells the delegate that there is a communication error.
  128. @param friendPicker The friend picker view controller that encountered the error.
  129. @param error An error object containing details of the error.
  130. */
  131. - (void)friendPickerViewController:(FBFriendPickerViewController *)friendPicker
  132. handleError:(NSError *)error;
  133. @end