Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // BlockEnumerator.m
- // Ross Utils Library
- //
- // Created by Richard Ross on 2/1/11.
- // Copyright 2011 Ultimate Computer Services Inc. All rights reserved.
- //
- #import "BlockEnumerator.h"
- MoveNextBlock MOVENEXT_NULL_BLOCK = ^ { return NO; };
- CurrentBlock CURRENT_NULL_BLOCK = ^ { return (id)(nil); };
- ResetBlock RESET_NULL_BLOCK = ^ { return; };
- DeallocBlock DEALLOC_NULL_BLOCK = ^ { return; };
- @implementation BlockEnumerator
- @synthesize moveNext=m_moveNext, current=m_current, reset=m_reset, dealloc=m_dealloc;
- -(id) init
- {
- if (self = [super init])
- {
- [self setMoveNext:MOVENEXT_NULL_BLOCK];
- [self setCurrent:CURRENT_NULL_BLOCK];
- [self setReset:RESET_NULL_BLOCK];
- [self setDealloc:DEALLOC_NULL_BLOCK];
- }
- return self;
- }
- -(BOOL) moveNext
- {
- if (m_moveNext == NULL)
- {
- return NO;
- }
- else return m_moveNext();
- }
- -(id) current
- {
- if (m_current == NULL)
- return nil;
- else return m_current();
- }
- -(void) reset
- {
- if (m_reset == NULL)
- return;
- else m_reset();
- }
- -(void) dealloc {
- m_dealloc();
- Block_release(m_moveNext);
- Block_release(m_current);
- Block_release(m_reset);
- Block_release(m_dealloc);
- [super dealloc];
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement