Advertisement
Guest User

Untitled

a guest
May 23rd, 2011
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. //
  2. // BlockEnumerator.m
  3. // Ross Utils Library
  4. //
  5. // Created by Richard Ross on 2/1/11.
  6. // Copyright 2011 Ultimate Computer Services Inc. All rights reserved.
  7. //
  8.  
  9. #import "BlockEnumerator.h"
  10.  
  11. MoveNextBlock MOVENEXT_NULL_BLOCK = ^ { return NO; };
  12. CurrentBlock CURRENT_NULL_BLOCK = ^ { return (id)(nil); };
  13. ResetBlock RESET_NULL_BLOCK = ^ { return; };
  14. DeallocBlock DEALLOC_NULL_BLOCK = ^ { return; };
  15.  
  16.  
  17. @implementation BlockEnumerator
  18.  
  19. @synthesize moveNext=m_moveNext, current=m_current, reset=m_reset, dealloc=m_dealloc;
  20.  
  21. -(id) init
  22. {
  23. if (self = [super init])
  24. {
  25. [self setMoveNext:MOVENEXT_NULL_BLOCK];
  26. [self setCurrent:CURRENT_NULL_BLOCK];
  27. [self setReset:RESET_NULL_BLOCK];
  28. [self setDealloc:DEALLOC_NULL_BLOCK];
  29. }
  30.  
  31. return self;
  32. }
  33.  
  34. -(BOOL) moveNext
  35. {
  36. if (m_moveNext == NULL)
  37. {
  38. return NO;
  39. }
  40. else return m_moveNext();
  41.  
  42. }
  43.  
  44. -(id) current
  45. {
  46. if (m_current == NULL)
  47. return nil;
  48.  
  49. else return m_current();
  50. }
  51.  
  52. -(void) reset
  53. {
  54. if (m_reset == NULL)
  55. return;
  56. else m_reset();
  57. }
  58.  
  59. -(void) dealloc {
  60. m_dealloc();
  61. Block_release(m_moveNext);
  62. Block_release(m_current);
  63. Block_release(m_reset);
  64. Block_release(m_dealloc);
  65. [super dealloc];
  66. }
  67.  
  68. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement