@class Chunk;
@protocol ChunkDelegate
@required
- (CGFloat)heightForChunk:(Chunk *)chunk;
@end
@interface ChunkController ()<ChunkDelegate>
@property (nonatomic, strong) Game *game;
@end
@implementation ChunkController
- (void)createChunks;
{
// create chunks here
Chunk *chunk = [[Chunk alloc] initWithDelegate:self]
}
- (CGFloat)heightForChunk:(Chunk *)chunk;
{
// calculate height for the chunk here
}
@end
@interface Chunk
@property (nonatomic, weak) id<ChunkDelegate> delegate;
- (instancetype)initWithDelegate:(id<ChunkDelegate>)delegate;
@end
@implementation Chunk
- (instancetype)initWithDelegate:(id<ChunkDelegate>)delegate;
{
self = [super init];
if (self) {
self.delegate = delegate;
}
return self;
}
@end