FBSDKUtility.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
  2. //
  3. // You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
  4. // copy, modify, and distribute this software in source code or binary form for use
  5. // in connection with the web services and APIs provided by Facebook.
  6. //
  7. // As with any software that integrates with the Facebook platform, your use of
  8. // this software is subject to the Facebook Developer Principles and Policies
  9. // [http://developers.facebook.com/policy/]. This copyright notice shall be
  10. // included in all copies or substantial portions of the software.
  11. //
  12. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  14. // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  15. // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  16. // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  17. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  18. #import <Foundation/Foundation.h>
  19. /**
  20. Class to contain common utility methods.
  21. */
  22. @interface FBSDKUtility : NSObject
  23. - (instancetype)init NS_UNAVAILABLE;
  24. + (instancetype)new NS_UNAVAILABLE;
  25. /**
  26. Parses a query string into a dictionary.
  27. @param queryString The query string value.
  28. @return A dictionary with the key/value pairs.
  29. */
  30. + (NSDictionary *)dictionaryWithQueryString:(NSString *)queryString;
  31. /**
  32. Constructs a query string from a dictionary.
  33. @param dictionary The dictionary with key/value pairs for the query string.
  34. @param errorRef If an error occurs, upon return contains an NSError object that describes the problem.
  35. @return Query string representation of the parameters.
  36. */
  37. + (NSString *)queryStringWithDictionary:(NSDictionary *)dictionary error:(NSError *__autoreleasing *)errorRef;
  38. /**
  39. Decodes a value from an URL.
  40. @param value The value to decode.
  41. @return The decoded value.
  42. */
  43. + (NSString *)URLDecode:(NSString *)value;
  44. /**
  45. Encodes a value for an URL.
  46. @param value The value to encode.
  47. @return The encoded value.
  48. */
  49. + (NSString *)URLEncode:(NSString *)value;
  50. /**
  51. Creates a timer using Grand Central Dispatch.
  52. @param interval The interval to fire the timer, in seconds.
  53. @param block The code block to execute when timer is fired.
  54. @return The dispatch handle.
  55. */
  56. + (dispatch_source_t)startGCDTimerWithInterval:(double)interval block:(dispatch_block_t)block;
  57. /**
  58. Stop a timer that was started by startGCDTimerWithInterval.
  59. @param timer The dispatch handle received from startGCDTimerWithInterval.
  60. */
  61. + (void)stopGCDTimer:(dispatch_source_t)timer;
  62. /**
  63. Get SHA256 hased string of NSString/NSData
  64. @param input The data that needs to be hashed, it could be NSString or NSData.
  65. */
  66. + (NSString *)SHA256Hash:(NSObject *)input;
  67. @end