diff --git a/BeeDebugger/Bee_Debug.h b/BeeDebugger/Bee_Debug.h index 5a3381d..1924232 100644 --- a/BeeDebugger/Bee_Debug.h +++ b/BeeDebugger/Bee_Debug.h @@ -33,6 +33,6 @@ #import "Bee_Precompile.h" #import "Bee.h" -@interface BeeDebugger +@interface BeeDebugger : NSObject + (void)show; @end diff --git a/BeeDebugger/Bee_DebugMessageBoard.h b/BeeDebugger/Bee_DebugMessageBoard.h index e2449a1..38413bc 100644 --- a/BeeDebugger/Bee_DebugMessageBoard.h +++ b/BeeDebugger/Bee_DebugMessageBoard.h @@ -36,6 +36,7 @@ #if defined(__BEE_DEBUGGER__) && __BEE_DEBUGGER__ #import "Bee_DebugDetailView.h" +#import "Bee_UITableBoard.h" #pragma mark - diff --git a/BeeDebugger/Bee_DebugMessageBoard.m b/BeeDebugger/Bee_DebugMessageBoard.m index fad2ee2..6713fed 100644 --- a/BeeDebugger/Bee_DebugMessageBoard.m +++ b/BeeDebugger/Bee_DebugMessageBoard.m @@ -108,12 +108,12 @@ - (void)setMessage:(BeeMessage *)message @implementation BeeDebugMessageCell -+ (CGSize)cellSize:(NSObject *)data bound:(CGSize)bound ++ (CGSize)sizeInBound:(CGSize)bound forData:(NSObject *)data { return CGSizeMake( bound.width, 50.0f ); } -- (void)cellLayout:(BeeUIGridCell *)cell bound:(CGSize)bound +- (void)layoutInBound:(CGSize)bound forCell:(BeeUIGridCell *)cell { CGRect timeFrame; timeFrame.size.width = 70.0f; @@ -165,73 +165,77 @@ - (void)load [self addSubview:_statusLabel]; } -- (void)bindData:(NSObject *)data +- (void)dataWillChange { - BeeMessage * msg = (BeeMessage *)data; - - NSDateFormatter * formatter = [[NSDateFormatter alloc] init]; - [formatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"US"] autorelease]]; - [formatter setDateFormat:@"hh:mm:ss"]; - NSDate * date2 = [NSDate dateWithTimeIntervalSince1970:msg.initTimeStamp]; - _timeLabel.text = [formatter stringFromDate:date2]; - [formatter release]; - - _nameLabel.text = msg.message; - - if ( msg.created ) - { - _statusLabel.text = @"Created"; - _statusLabel.textColor = [UIColor whiteColor]; - } - else if ( msg.sending ) - { - _statusLabel.text = [NSString stringWithFormat:@"Sending\n%dK / %dK", - [msg.request uploadBytes] / 1024, - [msg.request downloadBytes] / 1024]; - _statusLabel.textColor = [UIColor yellowColor]; - } - else if ( msg.succeed ) - { -// _statusLabel.text = [NSString stringWithFormat:@"Succeed\n%dK / %dK", -// [msg.request uploadBytes] / 1024, -// [msg.request downloadBytes] / 1024]; - _statusLabel.text = @"Succeed"; - _statusLabel.textColor = [UIColor greenColor]; - } - else if ( msg.failed ) + [super dataWillChange]; +} + +- (void)dataDidChanged +{ + BeeMessage * msg = (BeeMessage *)self.cellData; + if ( msg ) { - if ( msg.timeout ) + NSDateFormatter * formatter = [[NSDateFormatter alloc] init]; + [formatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"US"] autorelease]]; + [formatter setDateFormat:@"hh:mm:ss"]; + NSDate * date2 = [NSDate dateWithTimeIntervalSince1970:msg.initTimeStamp]; + _timeLabel.text = [formatter stringFromDate:date2]; + [formatter release]; + + _nameLabel.text = msg.message; + + if ( msg.created ) + { + _statusLabel.text = @"Created"; + _statusLabel.textColor = [UIColor whiteColor]; + } + else if ( msg.sending ) { - _statusLabel.text = @"Timeout"; - _statusLabel.textColor = [UIColor redColor]; + _statusLabel.text = [NSString stringWithFormat:@"Sending\n%dK / %dK", + [msg.request uploadBytes] / 1024, + [msg.request downloadBytes] / 1024]; + _statusLabel.textColor = [UIColor yellowColor]; + } + else if ( msg.succeed ) + { + // _statusLabel.text = [NSString stringWithFormat:@"Succeed\n%dK / %dK", + // [msg.request uploadBytes] / 1024, + // [msg.request downloadBytes] / 1024]; + _statusLabel.text = @"Succeed"; + _statusLabel.textColor = [UIColor greenColor]; + } + else if ( msg.failed ) + { + if ( msg.timeout ) + { + _statusLabel.text = @"Timeout"; + _statusLabel.textColor = [UIColor redColor]; + } + else + { + _statusLabel.text = @"Failed"; + _statusLabel.textColor = [UIColor redColor]; + } + } + else if ( msg.cancelled ) + { + _statusLabel.text = @"Cancelled"; + _statusLabel.textColor = [UIColor grayColor]; } else { - _statusLabel.text = @"Failed"; - _statusLabel.textColor = [UIColor redColor]; + _statusLabel.text = @""; + _statusLabel.textColor = [UIColor whiteColor]; } } - else if ( msg.cancelled ) - { - _statusLabel.text = @"Cancelled"; - _statusLabel.textColor = [UIColor grayColor]; - } else { - _statusLabel.text = @""; - _statusLabel.textColor = [UIColor whiteColor]; + SAFE_RELEASE_SUBVIEW( _nameLabel ); + SAFE_RELEASE_SUBVIEW( _timeLabel ); + SAFE_RELEASE_SUBVIEW( _statusLabel ); } } -- (void)unload -{ - SAFE_RELEASE_SUBVIEW( _nameLabel ); - SAFE_RELEASE_SUBVIEW( _timeLabel ); - SAFE_RELEASE_SUBVIEW( _statusLabel ); - - [super unload]; -} - @end #pragma mark - @@ -267,7 +271,7 @@ - (void)handleUISignal:(BeeUISignal *)signal - (void)handleTick:(NSTimeInterval)elapsed { - [self syncReloadData]; + [self reloadData]; } #pragma mark - @@ -277,7 +281,7 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa { NSObject * data = [[BeeDebugMessageModel sharedInstance].history objectAtIndex:indexPath.row]; CGSize bound = CGSizeMake( self.viewSize.width, 0.0f ); - return [BeeDebugMessageCell cellSize:data bound:bound].height; + return [BeeDebugMessageCell sizeInBound:bound forData:data].height; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section @@ -290,7 +294,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N BeeUITableViewCell * cell = (BeeUITableViewCell *)[self dequeueWithContentClass:[BeeDebugMessageCell class]]; if ( cell ) { - [cell bindData:[[BeeDebugMessageModel sharedInstance].history objectAtIndex:indexPath.row]]; + cell.cellData = [[BeeDebugMessageModel sharedInstance].history objectAtIndex:indexPath.row]; return cell; } diff --git a/BeeDebugger/Bee_DebugNetworkBoard.h b/BeeDebugger/Bee_DebugNetworkBoard.h index 6baa08a..3521048 100644 --- a/BeeDebugger/Bee_DebugNetworkBoard.h +++ b/BeeDebugger/Bee_DebugNetworkBoard.h @@ -38,6 +38,7 @@ #import "Bee_DebugPlotsView.h" #import "Bee_DebugSampleView.h" #import "Bee_DebugDetailView.h" +#import "Bee_UITableBoard.h" #pragma mark - diff --git a/BeeDebugger/Bee_DebugNetworkBoard.m b/BeeDebugger/Bee_DebugNetworkBoard.m index ac778fb..8f5b2c9 100644 --- a/BeeDebugger/Bee_DebugNetworkBoard.m +++ b/BeeDebugger/Bee_DebugNetworkBoard.m @@ -59,12 +59,12 @@ - (void)setRequest:(BeeRequest *)req @implementation BeeDebugNetworkCell -+ (CGSize)cellSize:(NSObject *)data bound:(CGSize)bound ++ (CGSize)sizeInBound:(CGSize)bound forData:(NSObject *)data { return CGSizeMake( bound.width, 50.0f ); } -- (void)cellLayout:(BeeUIGridCell *)cell bound:(CGSize)bound +- (void)layoutInBound:(CGSize)bound forCell:(BeeUIGridCell *)cell { CGRect timeFrame; timeFrame.size.width = 70.0f; @@ -126,59 +126,68 @@ - (void)unload [super unload]; } -- (void)bindData:(NSObject *)data +- (void)dataWillChange { - BeeRequest * req = (BeeRequest *)data; - - NSDateFormatter * formatter = [[NSDateFormatter alloc] init]; - [formatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"US"] autorelease]]; - [formatter setDateFormat:@"hh:mm:ss"]; - NSDate * date2 = [NSDate dateWithTimeIntervalSince1970:req.initTimeStamp]; - _timeLabel.text = [formatter stringFromDate:date2]; - [formatter release]; - - _urlLabel.text = [req.url absoluteString]; + [super dataWillChange]; +} - NSUInteger upSize = req.postLength; - NSUInteger downSize = [[req rawResponseData] length]; +- (void)dataDidChanged +{ + [super dataDidChanged]; - if ( req.created ) - { - _statusLabel.textColor = [UIColor whiteColor]; - _statusLabel.text = @"Pending"; - } - else if ( req.sending ) - { - _statusLabel.textColor = [UIColor yellowColor]; - _statusLabel.text = [NSString stringWithFormat:@"Sending\n%@/%@", - [BeeDebugUtility number2String:upSize], - [BeeDebugUtility number2String:downSize]]; - } - else if ( req.recving ) + BeeRequest * req = (BeeRequest *)self.cellData; + if ( req ) { - _statusLabel.textColor = [UIColor yellowColor]; - _statusLabel.text = [NSString stringWithFormat:@"Recving\n%@/%@", - [BeeDebugUtility number2String:upSize], - [BeeDebugUtility number2String:downSize]]; - } - else if ( req.failed ) - { - _statusLabel.textColor = [UIColor redColor]; - _statusLabel.text = [NSString stringWithFormat:@"Failed\nerr%d", req.responseStatusCode]; - } - else if ( req.succeed ) - { - _statusLabel.textColor = [UIColor greenColor]; - _statusLabel.text = [NSString stringWithFormat:@"Succeed\n%@/%@", - [BeeDebugUtility number2String:upSize], - [BeeDebugUtility number2String:downSize]]; + NSDateFormatter * formatter = [[NSDateFormatter alloc] init]; + [formatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"US"] autorelease]]; + [formatter setDateFormat:@"hh:mm:ss"]; + NSDate * date2 = [NSDate dateWithTimeIntervalSince1970:req.initTimeStamp]; + _timeLabel.text = [formatter stringFromDate:date2]; + [formatter release]; + + _urlLabel.text = [req.url absoluteString]; + + NSUInteger upSize = req.postLength; + NSUInteger downSize = [[req rawResponseData] length]; + + if ( req.created ) + { + _statusLabel.textColor = [UIColor whiteColor]; + _statusLabel.text = @"Pending"; + } + else if ( req.sending ) + { + _statusLabel.textColor = [UIColor yellowColor]; + _statusLabel.text = [NSString stringWithFormat:@"Sending\n%@/%@", + [BeeDebugUtility number2String:upSize], + [BeeDebugUtility number2String:downSize]]; + } + else if ( req.recving ) + { + _statusLabel.textColor = [UIColor yellowColor]; + _statusLabel.text = [NSString stringWithFormat:@"Recving\n%@/%@", + [BeeDebugUtility number2String:upSize], + [BeeDebugUtility number2String:downSize]]; + } + else if ( req.failed ) + { + _statusLabel.textColor = [UIColor redColor]; + _statusLabel.text = [NSString stringWithFormat:@"Failed\nerr%d", req.responseStatusCode]; + } + else if ( req.succeed ) + { + _statusLabel.textColor = [UIColor greenColor]; + _statusLabel.text = [NSString stringWithFormat:@"Succeed\n%@/%@", + [BeeDebugUtility number2String:upSize], + [BeeDebugUtility number2String:downSize]]; -// _statusLabel.text = @"Succeed"; - } - else if ( req.cancelled ) - { - _statusLabel.textColor = [UIColor grayColor]; - _statusLabel.text = @"Cancelled"; + // _statusLabel.text = @"Succeed"; + } + else if ( req.cancelled ) + { + _statusLabel.textColor = [UIColor grayColor]; + _statusLabel.text = @"Cancelled"; + } } } @@ -233,7 +242,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N BeeUITableViewCell * cell = [self dequeueWithContentClass:[BeeDebugNetworkCell class]]; if ( cell ) { - [cell bindData:[[BeeDebugNetworkModel sharedInstance].history objectAtIndex:indexPath.row]]; + cell.cellData = [[BeeDebugNetworkModel sharedInstance].history objectAtIndex:indexPath.row]; } return cell; } @@ -241,7 +250,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { CGSize bound = CGSizeMake( self.viewSize.width, 0.0f ); - return [BeeDebugNetworkCell cellSize:nil bound:bound].height; + return [BeeDebugNetworkCell sizeInBound:bound forData:nil].height; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath diff --git a/BeeDebugger/Bee_DebugSandboxBoard.h b/BeeDebugger/Bee_DebugSandboxBoard.h index 5cdc500..7cca0ae 100644 --- a/BeeDebugger/Bee_DebugSandboxBoard.h +++ b/BeeDebugger/Bee_DebugSandboxBoard.h @@ -39,6 +39,7 @@ #import "Bee_DebugPlotsView.h" #import "Bee_DebugSampleView.h" #import "Bee_DebugDetailView.h" +#import "Bee_UITableBoard.h" #pragma mark - diff --git a/BeeDebugger/Bee_DebugSandboxBoard.m b/BeeDebugger/Bee_DebugSandboxBoard.m index 72ed619..981b424 100644 --- a/BeeDebugger/Bee_DebugSandboxBoard.m +++ b/BeeDebugger/Bee_DebugSandboxBoard.m @@ -46,12 +46,12 @@ @implementation BeeDebugSandboxCell -+ (CGSize)cellSize:(NSObject *)data bound:(CGSize)bound ++ (CGSize)sizeInBound:(CGSize)bound forData:(NSObject *)data { return CGSizeMake( bound.width, 50.0f ); } -- (void)cellLayout:(BeeUIGridCell *)cell bound:(CGSize)bound +- (void)layoutInBound:(CGSize)bound forCell:(BeeUIGridCell *)cell { CGRect iconFrame; iconFrame.size.width = bound.height; @@ -99,12 +99,17 @@ - (void)load _sizeLabel.font = [UIFont boldSystemFontOfSize:13.0f]; _sizeLabel.lineBreakMode = UILineBreakModeClip; _sizeLabel.numberOfLines = 1; - [self addSubview:_sizeLabel]; + [self addSubview:_sizeLabel]; } -- (void)bindData:(NSObject *)data +- (void)dataWillChange { - NSString * filePath = (NSString *)data; + [super dataWillChange]; +} + +- (void)dataDidChanged +{ + NSString * filePath = (NSString *)self.cellData; if ( [filePath isEqualToString:@".."] ) { _nameLabel.text = @".."; @@ -123,7 +128,7 @@ - (void)bindData:(NSObject *)data } } - _nameLabel.text = [(NSString *)data lastPathComponent]; + _nameLabel.text = [(NSString *)filePath lastPathComponent]; _iconView.image = __IMAGE( isDirectory ? @"folder.png" : @"file.png" ); _sizeLabel.text = @""; @@ -156,12 +161,12 @@ @implementation BeeDebugToolCell DEF_SIGNAL( REFRESH ) DEF_SIGNAL( DELETE_ALL ) -+ (CGSize)cellSize:(NSObject *)data bound:(CGSize)bound ++ (CGSize)sizeInBound:(CGSize)bound forData:(NSObject *)data { return CGSizeMake( bound.width, 40.0f ); } -- (void)cellLayout:(BeeUIGridCell *)cell bound:(CGSize)bound +- (void)layoutInBound:(CGSize)bound forCell:(BeeUIGridCell *)cell { CGRect buttonFrame; buttonFrame.size.width = 72.0f; @@ -220,7 +225,7 @@ - (void)load - (void)setPath:(NSString *)path fileCount:(NSUInteger)count { - _folderName.text = [NSString stringWithFormat:@"Total %lu file(s)", count]; + _folderName.text = [NSString stringWithFormat:@"Total %u file(s)", count]; } - (void)unload @@ -392,7 +397,7 @@ - (void)deleteAll - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { CGSize bound = CGSizeMake( self.viewSize.width, 0.0f ); - return [BeeDebugSandboxCell cellSize:nil bound:bound].height; + return [BeeDebugSandboxCell sizeInBound:bound forData:nil].height; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section @@ -408,12 +413,11 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N NSString * file = [_fileArray objectAtIndex:indexPath.row]; if ( [file isEqualToString:@".."] ) { - [cell bindData:file]; + cell.cellData = file; } else { - NSString * path = [NSString stringWithFormat:@"%@/%@", self.filePath, file]; - [cell bindData:path]; + cell.cellData = [NSString stringWithFormat:@"%@/%@", self.filePath, file]; } return cell; } diff --git a/BeeDebugger/Bee_DebugViewBoard.h b/BeeDebugger/Bee_DebugViewBoard.h index 87cea71..5c1f885 100644 --- a/BeeDebugger/Bee_DebugViewBoard.h +++ b/BeeDebugger/Bee_DebugViewBoard.h @@ -38,6 +38,7 @@ #import "Bee_DebugPlotsView.h" #import "Bee_DebugSampleView.h" #import "Bee_DebugDetailView.h" +#import "Bee_UITableBoard.h" #pragma mark - diff --git a/BeeDebugger/Bee_DebugViewBoard.m b/BeeDebugger/Bee_DebugViewBoard.m index 5bf50c0..cbe034a 100644 --- a/BeeDebugger/Bee_DebugViewBoard.m +++ b/BeeDebugger/Bee_DebugViewBoard.m @@ -115,12 +115,12 @@ - (void)setBoard:(BeeUIBoard *)board @implementation BeeDebugViewCell -+ (CGSize)cellSize:(NSObject *)data bound:(CGSize)bound ++ (CGSize)sizeInBound:(CGSize)bound forData:(NSObject *)data { return CGSizeMake( bound.width, 50.0f ); } -- (void)cellLayout:(BeeUIGridCell *)cell bound:(CGSize)bound +- (void)layoutInBound:(CGSize)bound forCell:(BeeUIGridCell *)cell { _plotView.frame = CGSizeMakeBound( bound ); @@ -235,73 +235,83 @@ - (NSUInteger)countUIImageViewsIn:(UIView *)view return subCount; } -- (void)bindData:(NSObject *)data +- (void)dataWillChange { - BeeUIBoard * board = (BeeUIBoard *)data; - - NSArray * plots = [[BeeDebugViewModel sharedInstance] plotsForBoard:board]; - - [_plotView setPlots:plots]; - [_plotView setLowerBound:[BeeDebugViewModel sharedInstance].lowerBound]; - [_plotView setUpperBound:[BeeDebugViewModel sharedInstance].upperBound]; - [_plotView setNeedsDisplay]; - - NSDateFormatter * formatter = [[NSDateFormatter alloc] init]; - [formatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"US"] autorelease]]; - [formatter setDateFormat:@"hh:mm:ss"]; - _timeLabel.text = [NSString stringWithFormat:@"%@", [formatter stringFromDate:board.createDate]]; - [formatter release]; + [super dataWillChange]; +} -// _timeLabel.text = [NSString stringWithFormat:@"#%d", board.createSeq]; - - if ( [[[board class] description] hasPrefix:@"BeeDebug"] ) - { - _nameLabel.textColor = [UIColor lightGrayColor]; - _nameLabel.text = [[board class] description]; - } - else +- (void)dataDidChanged +{ + BeeUIBoard * board = (BeeUIBoard *)self.cellData; + if ( board ) { - _nameLabel.textColor = [UIColor whiteColor]; - _nameLabel.text = [[board class] description]; - } - - NSUInteger subviewCount = [self countSubviewsIn:board.view]; - NSUInteger imageviewCount = [self countUIImageViewsIn:board.view]; - -// if ( subviewCount >= 100 ) -// { -// _countLabel.textColor = [UIColor redColor]; -// } -// else if ( subviewCount >= 50 ) -// { -// _countLabel.textColor = [UIColor yellowColor]; -// } -// else -// { + NSArray * plots = [[BeeDebugViewModel sharedInstance] plotsForBoard:board]; + + [_plotView setPlots:plots]; + [_plotView setLowerBound:[BeeDebugViewModel sharedInstance].lowerBound]; + [_plotView setUpperBound:[BeeDebugViewModel sharedInstance].upperBound]; + [_plotView setNeedsDisplay]; + + NSDateFormatter * formatter = [[NSDateFormatter alloc] init]; + [formatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"US"] autorelease]]; + [formatter setDateFormat:@"hh:mm:ss"]; + _timeLabel.text = [NSString stringWithFormat:@"%@", [formatter stringFromDate:board.createDate]]; + [formatter release]; + + // _timeLabel.text = [NSString stringWithFormat:@"#%d", board.createSeq]; + + if ( [[[board class] description] hasPrefix:@"BeeDebug"] ) + { + _nameLabel.textColor = [UIColor lightGrayColor]; + _nameLabel.text = [[board class] description]; + } + else + { + _nameLabel.textColor = [UIColor whiteColor]; + _nameLabel.text = [[board class] description]; + } + + NSUInteger subviewCount = [self countSubviewsIn:board.view]; + NSUInteger imageviewCount = [self countUIImageViewsIn:board.view]; + + // if ( subviewCount >= 100 ) + // { + // _countLabel.textColor = [UIColor redColor]; + // } + // else if ( subviewCount >= 50 ) + // { + // _countLabel.textColor = [UIColor yellowColor]; + // } + // else + // { _countLabel.textColor = [UIColor lightGrayColor]; -// } - - _countLabel.text = [NSString stringWithFormat:@"%d subviews, %d images", subviewCount, imageviewCount]; - - if ( board.deactivated ) - { - _statusLabel.textColor = [UIColor grayColor]; - _statusLabel.text = @"Deactivated"; - } - else if ( board.deactivating ) - { - _statusLabel.textColor = [UIColor yellowColor]; - _statusLabel.text = @"Deactivating"; - } - else if ( board.activating ) - { - _statusLabel.textColor = [UIColor yellowColor]; - _statusLabel.text = @"Activating"; + // } + + _countLabel.text = [NSString stringWithFormat:@"%d subviews, %d images", subviewCount, imageviewCount]; + + if ( board.deactivated ) + { + _statusLabel.textColor = [UIColor grayColor]; + _statusLabel.text = @"Deactivated"; + } + else if ( board.deactivating ) + { + _statusLabel.textColor = [UIColor yellowColor]; + _statusLabel.text = @"Deactivating"; + } + else if ( board.activating ) + { + _statusLabel.textColor = [UIColor yellowColor]; + _statusLabel.text = @"Activating"; + } + else if ( board.activated ) + { + _statusLabel.textColor = [UIColor greenColor]; + _statusLabel.text = @"Activated"; + } } - else if ( board.activated ) + else { - _statusLabel.textColor = [UIColor greenColor]; - _statusLabel.text = @"Activated"; } } @@ -366,7 +376,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N BeeUITableViewCell * cell = [self dequeueWithContentClass:[BeeDebugViewCell class]]; if ( cell ) { - [cell bindData:[[BeeUIBoard allBoards] objectAtIndex:indexPath.row]]; + cell.cellData = [[BeeUIBoard allBoards] objectAtIndex:indexPath.row]; } return cell; } @@ -374,7 +384,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { CGSize bound = CGSizeMake( self.viewSize.width, 0.0f ); - return [BeeDebugViewCell cellSize:nil bound:bound].height; + return [BeeDebugViewCell sizeInBound:bound forData:nil].height; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath diff --git a/BeeDebugger/Bee_DebugWindow.m b/BeeDebugger/Bee_DebugWindow.m index ee0b1a8..8aa162c 100644 --- a/BeeDebugger/Bee_DebugWindow.m +++ b/BeeDebugger/Bee_DebugWindow.m @@ -151,86 +151,101 @@ - (void)handleUISignal:(BeeUISignal *)signal { [super handleUISignal:signal]; - if ( [signal isKindOf:BeeUIBoard.SIGNAL] ) + if ( [signal is:@"CLOSE_TOUCHED"] ) { - if ( [signal is:BeeUIBoard.CREATE_VIEWS] ) - { - [self append:[BeeUIStack stack:@"Dash" firstBoard:[BeeDebugDashBoard sharedInstance]]]; - [self append:[BeeUIStack stack:@"View" firstBoard:[BeeDebugViewBoard sharedInstance]]]; - [self append:[BeeUIStack stack:@"Msg" firstBoard:[BeeDebugMessageBoard sharedInstance]]]; - [self append:[BeeUIStack stack:@"Net" firstBoard:[BeeDebugNetworkBoard sharedInstance]]]; - [self append:[BeeUIStack stack:@"File" firstBoard:[BeeDebugSandboxBoard sharedInstance]]]; + [BeeDebugWindow sharedInstance].hidden = YES; + [BeeDebugHeatmap sharedInstance].hidden = YES; + [BeeDebugShortcut sharedInstance].hidden = NO; + } +} + +- (void)handleUISignal_BeeUIBoard:(BeeUISignal *)signal +{ + [super handleUISignal:signal]; + + if ( [signal is:BeeUIBoard.CREATE_VIEWS] ) + { + [self append:[BeeUIStack stack:@"Dash" firstBoard:[BeeDebugDashBoard sharedInstance]]]; + [self append:[BeeUIStack stack:@"View" firstBoard:[BeeDebugViewBoard sharedInstance]]]; + [self append:[BeeUIStack stack:@"Msg" firstBoard:[BeeDebugMessageBoard sharedInstance]]]; + [self append:[BeeUIStack stack:@"Net" firstBoard:[BeeDebugNetworkBoard sharedInstance]]]; + [self append:[BeeUIStack stack:@"File" firstBoard:[BeeDebugSandboxBoard sharedInstance]]]; // [self append:[BeeUIStack stack:@"Crash" firstBoard:nil]]; - [self present:[self.stacks objectAtIndex:0]]; - - CGRect bottomFrame; - bottomFrame.size.width = self.viewSize.width; - bottomFrame.size.height = 44.0f; - bottomFrame.origin.x = 0.0f; - bottomFrame.origin.y = self.viewSize.height - bottomFrame.size.height; - - _bottomView = [[UIView alloc] initWithFrame:bottomFrame]; - _bottomView.backgroundColor = [UIColor clearColor]; - _bottomView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.4f]; - _bottomView.layer.borderWidth = 1.0f; - _bottomView.layer.borderColor = [UIColor grayColor].CGColor; - [self.view addSubview:_bottomView]; - - CGRect segFrame; - segFrame.size.width = self.viewSize.width - 44.0f - 10.0f; - segFrame.size.height = 30.0f; - segFrame.origin.x = 10.0f; - segFrame.origin.y = (bottomFrame.size.height - segFrame.size.height) / 2.0f; - - BeeUISegmentedControl * segmentControl = [[[BeeUISegmentedControl alloc] initWithFrame:segFrame] autorelease]; - for ( BeeUIStack * stack in self.stacks ) - { - [segmentControl addTitle:stack.name]; - } - segmentControl.segmentedControlStyle = UISegmentedControlStyleBezeled; - segmentControl.tintColor = [UIColor grayColor]; - [segmentControl setSelectedSegmentIndex:0]; - [_bottomView addSubview:segmentControl]; - - CGRect closeFrame; - closeFrame.size.width = 44.0f; - closeFrame.size.height = 44.0f; - closeFrame.origin.x = self.viewSize.width - closeFrame.size.width; - closeFrame.origin.y = (bottomFrame.size.height - closeFrame.size.height) / 2.0f; - - BeeUIButton * closeView = [[[BeeUIButton alloc] initWithFrame:closeFrame] autorelease]; - closeView.stateNormal.image = __IMAGE( @"close.png" ); - [closeView addSignal:@"CLOSE_TOUCHED" forControlEvents:UIControlEventTouchUpInside]; - [_bottomView addSubview:closeView]; - } - else if ( [signal is:BeeUIBoard.DELETE_VIEWS] ) - { - SAFE_RELEASE_SUBVIEW( _bottomView ); - } - else if ( [signal is:BeeUIBoard.WILL_APPEAR] ) + [self present:[self.stacks objectAtIndex:0]]; + + CGRect bottomFrame; + bottomFrame.size.width = self.viewSize.width; + bottomFrame.size.height = 44.0f; + bottomFrame.origin.x = 0.0f; + bottomFrame.origin.y = self.viewSize.height - bottomFrame.size.height; + + _bottomView = [[UIView alloc] initWithFrame:bottomFrame]; + _bottomView.backgroundColor = [UIColor clearColor]; + _bottomView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.4f]; + _bottomView.layer.borderWidth = 1.0f; + _bottomView.layer.borderColor = [UIColor grayColor].CGColor; + [self.view addSubview:_bottomView]; + + CGRect segFrame; + segFrame.size.width = self.viewSize.width - 44.0f - 10.0f; + segFrame.size.height = 30.0f; + segFrame.origin.x = 10.0f; + segFrame.origin.y = (bottomFrame.size.height - segFrame.size.height) / 2.0f; + + BeeUISegmentedControl * segmentControl = [[[BeeUISegmentedControl alloc] initWithFrame:segFrame] autorelease]; + for ( BeeUIStack * stack in self.stacks ) { - + [segmentControl addTitle:stack.name]; } - else if ( [signal is:BeeUIBoard.DID_DISAPPEAR] ) - { + segmentControl.segmentedControlStyle = UISegmentedControlStyleBezeled; + segmentControl.tintColor = [UIColor grayColor]; + [segmentControl setSelectedSegmentIndex:0]; + [_bottomView addSubview:segmentControl]; + + CGRect closeFrame; + closeFrame.size.width = 44.0f; + closeFrame.size.height = 44.0f; + closeFrame.origin.x = self.viewSize.width - closeFrame.size.width; + closeFrame.origin.y = (bottomFrame.size.height - closeFrame.size.height) / 2.0f; + + BeeUIButton * closeView = [[[BeeUIButton alloc] initWithFrame:closeFrame] autorelease]; + closeView.stateNormal.image = __IMAGE( @"close.png" ); + [closeView addSignal:@"CLOSE_TOUCHED" forControlEvents:UIControlEventTouchUpInside]; + [_bottomView addSubview:closeView]; + } + else if ( [signal is:BeeUIBoard.DELETE_VIEWS] ) + { + SAFE_RELEASE_SUBVIEW( _bottomView ); + } + else if ( [signal is:BeeUIBoard.WILL_APPEAR] ) + { + + } + else if ( [signal is:BeeUIBoard.DID_DISAPPEAR] ) + { - } } - else if ( [signal is:BeeUIStackGroup.INDEX_CHANGED] ) +} + +- (void)handleUISignal_BeeUIStackGroup:(BeeUISignal *)signal +{ + [super handleUISignal:signal]; + + if ( [signal is:BeeUIStackGroup.INDEX_CHANGED] ) { [self.view bringSubviewToFront:_bottomView]; } - else if ( [signal is:BeeUISegmentedControl.HIGHLIGHT_CHANGED] ) +} + +- (void)handleUISignal_BeeUISegmentedControl:(BeeUISignal *)signal +{ + [super handleUISignal:signal]; + + if ( [signal is:BeeUISegmentedControl.HIGHLIGHT_CHANGED] ) { BeeUISegmentedControl * segmentControl = (BeeUISegmentedControl *)signal.source; [self present:[self.stacks objectAtIndex:segmentControl.selectedSegmentIndex]]; } - else if ( [signal is:@"CLOSE_TOUCHED"] ) - { - [BeeDebugWindow sharedInstance].hidden = YES; - [BeeDebugHeatmap sharedInstance].hidden = YES; - [BeeDebugShortcut sharedInstance].hidden = NO; - } } @end diff --git a/BeeFramework/Bee.h b/BeeFramework/Bee.h index 757ba49..6cc354f 100644 --- a/BeeFramework/Bee.h +++ b/BeeFramework/Bee.h @@ -31,36 +31,5 @@ // #import "Bee_Precompile.h" - -// Foundation -#import "Bee_Log.h" -#import "Bee_Keychain.h" -#import "Bee_Performance.h" -#import "Bee_Runtime.h" -#import "Bee_Sandbox.h" -#import "Bee_SystemInfo.h" -#import "Bee_Thread.h" -#import "Bee_Cache.h" -#import "Bee_Network.h" - -#import "NSArray+BeeExtension.h" -#import "NSData+BeeExtension.h" -#import "NSDate+BeeExtension.h" -#import "NSDictionary+BeeExtension.h" -#import "NSNumber+BeeExtension.h" -#import "NSObject+BeeNotification.h" -#import "NSObject+BeeProperty.h" -#import "NSObject+BeeTicker.h" -#import "NSString+BeeExtension.h" - -// Storage - -#import "Bee_ActiveRecord.h" -#import "Bee_Database.h" - -// MVC -#import "Bee_Model.h" -#import "Bee_View.h" -#import "Bee_Controller.h" - - +#import "Bee_Core.h" +#import "Bee_MVC.h" diff --git a/BeeFramework/Bee_Precompile.h b/BeeFramework/Bee_Precompile.h index cd61bfc..ee41dab 100644 --- a/BeeFramework/Bee_Precompile.h +++ b/BeeFramework/Bee_Precompile.h @@ -42,3 +42,8 @@ #define __BEE_DEBUGGER__ (1) // 是否显示“小虫子” #define __BEE_CRASHLOG__ (0) // (未完成) #define __BEE_PERFORMANCE__ (0) // 是否开启性能测试 +#define __BEE_UNITTEST__ (1) // 是否UnitTest +#define __BEE_WIREFRAME__ (1) // 是否显示WireFrame + +#define __BEE_SELECTOR_STYLE1__ (1) // handle + ClassName +#define __BEE_SELECTOR_STYLE2__ (1) // handleXXX + ClassName + MethodName diff --git a/BeeFramework/Contributors.txt b/BeeFramework/Contributors.txt deleted file mode 100755 index 462dac7..0000000 --- a/BeeFramework/Contributors.txt +++ /dev/null @@ -1,4 +0,0 @@ - -感谢所有活跃在QQ群里的童鞋们!! - -名字略..... diff --git a/BeeFramework/Storage/Bee_DatabaseTest.h b/BeeFramework/Core/Bee_Core.h similarity index 91% rename from BeeFramework/Storage/Bee_DatabaseTest.h rename to BeeFramework/Core/Bee_Core.h index 131d784..1a781ca 100644 --- a/BeeFramework/Storage/Bee_DatabaseTest.h +++ b/BeeFramework/Core/Bee_Core.h @@ -27,14 +27,11 @@ // IN THE SOFTWARE. // // -// Bee_DatabaseTest.h +// Bee_Core.h // #import "Bee_Precompile.h" -#import "Bee_Database.h" - -#pragma mark - - -@interface BeeDatabaseTest : NSObject -+ (void)run; -@end +#import "Bee_Foundation.h" +#import "Bee_Network.h" +#import "Bee_Storage.h" +#import "Bee_UnitTest.h" diff --git a/BeeFramework/Core/Foundation/Bee_Foundation.h b/BeeFramework/Core/Foundation/Bee_Foundation.h new file mode 100644 index 0000000..f54e7d8 --- /dev/null +++ b/BeeFramework/Core/Foundation/Bee_Foundation.h @@ -0,0 +1,54 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_Foundation.h +// + +#import "Bee_Precompile.h" + +// Foundation +#import "Bee_Log.h" +#import "Bee_Performance.h" +#import "Bee_Runtime.h" +#import "Bee_Sandbox.h" +#import "Bee_Singleton.h" +#import "Bee_SystemInfo.h" +#import "Bee_Thread.h" + +// Foundation-Extension +#import "NSArray+BeeExtension.h" +#import "NSData+BeeExtension.h" +#import "NSDate+BeeExtension.h" +#import "NSDictionary+BeeExtension.h" +#import "NSNumber+BeeExtension.h" +#import "NSObject+BeeNotification.h" +#import "NSObject+BeeProperty.h" +#import "NSObject+BeeTicker.h" +#import "NSObject+BeeTypeConversion.h" +#import "NSString+BeeExtension.h" diff --git a/BeeFramework/Core/Foundation/Bee_Foundation.mm b/BeeFramework/Core/Foundation/Bee_Foundation.mm new file mode 100644 index 0000000..2ddedd5 --- /dev/null +++ b/BeeFramework/Core/Foundation/Bee_Foundation.mm @@ -0,0 +1,33 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_Foundation.h +// + +#import "Bee_Foundation.h" diff --git a/BeeFramework/Foundation/Bee_Log.h b/BeeFramework/Core/Foundation/Bee_Log.h similarity index 100% rename from BeeFramework/Foundation/Bee_Log.h rename to BeeFramework/Core/Foundation/Bee_Log.h diff --git a/BeeFramework/Foundation/Bee_Log.mm b/BeeFramework/Core/Foundation/Bee_Log.mm similarity index 99% rename from BeeFramework/Foundation/Bee_Log.mm rename to BeeFramework/Core/Foundation/Bee_Log.mm index 96c0610..2ba36fe 100644 --- a/BeeFramework/Foundation/Bee_Log.mm +++ b/BeeFramework/Core/Foundation/Bee_Log.mm @@ -67,7 +67,7 @@ { NSLog( [format description], nil ); } - + va_end( args ); #endif // #if defined(__BEE_LOG__) && __BEE_LOG__ diff --git a/BeeFramework/Foundation/Bee_Performance.h b/BeeFramework/Core/Foundation/Bee_Performance.h similarity index 90% rename from BeeFramework/Foundation/Bee_Performance.h rename to BeeFramework/Core/Foundation/Bee_Performance.h index 019508c..d81787e 100644 --- a/BeeFramework/Foundation/Bee_Performance.h +++ b/BeeFramework/Core/Foundation/Bee_Performance.h @@ -78,14 +78,25 @@ #pragma mark - +@interface BeePerformanceRecord : NSObject +{ + NSTimeInterval _timestamp; + NSTimeInterval _consume; +} +@end + +#pragma mark - + @interface BeePerformance : NSObject { + NSMutableDictionary * _records; NSMutableDictionary * _tags; } AS_SINGLETON( BeePerformance ); -@property (nonatomic, retain) NSMutableDictionary * tags; +@property (nonatomic, readonly) NSMutableDictionary * records; +@property (nonatomic, retain) NSMutableDictionary * tags; + (double)timestamp; @@ -93,4 +104,7 @@ AS_SINGLETON( BeePerformance ); + (double)between:(NSString *)tag1 and:(NSString *)tag2; + (double)between:(NSString *)tag1 and:(NSString *)tag2 remove:(BOOL)remove; ++ (void)watch:(Class)clazz; ++ (void)watch:(Class)clazz selector:(SEL)selector; + @end diff --git a/BeeFramework/Foundation/Bee_Performance.mm b/BeeFramework/Core/Foundation/Bee_Performance.mm similarity index 91% rename from BeeFramework/Foundation/Bee_Performance.mm rename to BeeFramework/Core/Foundation/Bee_Performance.mm index a72c017..0b0394a 100644 --- a/BeeFramework/Foundation/Bee_Performance.mm +++ b/BeeFramework/Core/Foundation/Bee_Performance.mm @@ -32,6 +32,7 @@ #import "Bee_Precompile.h" #import "Bee_Performance.h" +#include #pragma mark - @@ -39,6 +40,7 @@ @implementation BeePerformance DEF_SINGLETON( BeePerformance ); +@synthesize records = _records; @synthesize tags = _tags; - (id)init @@ -46,6 +48,7 @@ - (id)init self = [super init]; if ( self ) { + _records = [[NSMutableDictionary alloc] init]; _tags = [[NSMutableDictionary alloc] init]; } return self; @@ -56,6 +59,9 @@ - (void)dealloc [_tags removeAllObjects]; [_tags release]; + [_records removeAllObjects]; + [_records release]; + [super dealloc]; } @@ -109,4 +115,14 @@ + (double)between:(NSString *)tag1 and:(NSString *)tag2 remove:(BOOL)remove return time; } ++ (void)watch:(Class)clazz +{ + [self watch:clazz selector:nil]; +} + ++ (void)watch:(Class)clazz selector:(SEL)selector +{ + // TODO: +} + @end diff --git a/BeeFramework/Foundation/Bee_Runtime.h b/BeeFramework/Core/Foundation/Bee_Runtime.h similarity index 90% rename from BeeFramework/Foundation/Bee_Runtime.h rename to BeeFramework/Core/Foundation/Bee_Runtime.h index 7578143..9753e5b 100644 --- a/BeeFramework/Foundation/Bee_Runtime.h +++ b/BeeFramework/Core/Foundation/Bee_Runtime.h @@ -80,6 +80,23 @@ AS_INT( TYPE_NATIVEC ) #pragma mark - +@interface BeeTypeEncoding : NSObject + +AS_INT( UNKNOWN ) +AS_INT( OBJECT ) +AS_INT( NSNUMBER ) +AS_INT( NSSTRING ) +AS_INT( NSARRAY ) +AS_INT( NSDICTIONARY ) +AS_INT( NSDATE ) + ++ (NSUInteger)typeOf:(const char *)attr; ++ (NSString *)classNameOf:(const char *)attr; + +@end + +#pragma mark - + @interface BeeRuntime : NSObject + (id)allocByClass:(Class)clazz; diff --git a/BeeFramework/Foundation/Bee_Runtime.mm b/BeeFramework/Core/Foundation/Bee_Runtime.mm similarity index 71% rename from BeeFramework/Foundation/Bee_Runtime.mm rename to BeeFramework/Core/Foundation/Bee_Runtime.mm index fd6acf9..66b153f 100644 --- a/BeeFramework/Foundation/Bee_Runtime.mm +++ b/BeeFramework/Core/Foundation/Bee_Runtime.mm @@ -174,6 +174,162 @@ - (void)dealloc #pragma mark - +@implementation BeeTypeEncoding + +DEF_INT( UNKNOWN, 0 ) +DEF_INT( OBJECT, 1 ) +DEF_INT( NSNUMBER, 2 ) +DEF_INT( NSSTRING, 3 ) +DEF_INT( NSARRAY, 4 ) +DEF_INT( NSDICTIONARY, 5 ) +DEF_INT( NSDATE, 6 ) + ++ (NSUInteger)typeOf:(const char *)attr +{ + if ( attr[0] != 'T' ) + return BeeTypeEncoding.UNKNOWN; + + const char * type = &attr[1]; + if ( type[0] == '@' ) + { + if ( type[1] != '"' ) + return BeeTypeEncoding.UNKNOWN; + + char typeClazz[128] = { 0 }; + + const char * clazz = &type[2]; + const char * clazzEnd = strchr( clazz, '"' ); + + if ( clazzEnd && clazz != clazzEnd ) + { + unsigned int size = (unsigned int)(clazzEnd - clazz); + strncpy( &typeClazz[0], clazz, size ); + } + + if ( 0 == strcmp((const char *)typeClazz, "NSNumber") ) + { + return BeeTypeEncoding.NSNUMBER; + } + else if ( 0 == strcmp((const char *)typeClazz, "NSString") ) + { + return BeeTypeEncoding.NSSTRING; + } + else if ( 0 == strcmp((const char *)typeClazz, "NSDate") ) + { + return BeeTypeEncoding.NSDATE; + } + else if ( 0 == strcmp((const char *)typeClazz, "NSArray") ) + { + return BeeTypeEncoding.NSARRAY; + } + else if ( 0 == strcmp((const char *)typeClazz, "NSDictionary") ) + { + return BeeTypeEncoding.NSDICTIONARY; + } + else + { + return BeeTypeEncoding.OBJECT; + } + } + else if ( type[0] == '[' ) + { + return BeeTypeEncoding.UNKNOWN; + } + else if ( type[0] == '{' ) + { + return BeeTypeEncoding.UNKNOWN; + } + else + { + if ( type[0] == 'c' || type[0] == 'C' ) + { + return BeeTypeEncoding.UNKNOWN; + } + else if ( type[0] == 'i' || type[0] == 's' || type[0] == 'l' || type[0] == 'q' ) + { + return BeeTypeEncoding.UNKNOWN; + } + else if ( type[0] == 'I' || type[0] == 'S' || type[0] == 'L' || type[0] == 'Q' ) + { + return BeeTypeEncoding.UNKNOWN; + } + else if ( type[0] == 'f' ) + { + return BeeTypeEncoding.UNKNOWN; + } + else if ( type[0] == 'd' ) + { + return BeeTypeEncoding.UNKNOWN; + } + else if ( type[0] == 'B' ) + { + return BeeTypeEncoding.UNKNOWN; + } + else if ( type[0] == 'v' ) + { + return BeeTypeEncoding.UNKNOWN; + } + else if ( type[0] == '*' ) + { + return BeeTypeEncoding.UNKNOWN; + } + else if ( type[0] == ':' ) + { + return BeeTypeEncoding.UNKNOWN; + } + else if ( 0 == strcmp(type, "bnum") ) + { + return BeeTypeEncoding.UNKNOWN; + } + else if ( type[0] == '^' ) + { + return BeeTypeEncoding.UNKNOWN; + } + else if ( type[0] == '?' ) + { + return BeeTypeEncoding.UNKNOWN; + } + else + { + return BeeTypeEncoding.UNKNOWN; + } + } + + return BeeTypeEncoding.UNKNOWN; +} + ++ (NSString *)classNameOf:(const char *)attr +{ + if ( attr[0] != 'T' ) + return nil; + + const char * type = &attr[1]; + if ( type[0] == '@' ) + { + if ( type[1] != '"' ) + return nil; + + char typeClazz[128] = { 0 }; + + const char * clazz = &type[2]; + const char * clazzEnd = strchr( clazz, '"' ); + + if ( clazzEnd && clazz != clazzEnd ) + { + unsigned int size = (unsigned int)(clazzEnd - clazz); + strncpy( &typeClazz[0], clazz, size ); + } + + return [NSString stringWithUTF8String:typeClazz]; + } + + return nil; +} + +@end + +#pragma mark - + @implementation BeeRuntime + (id)allocByClass:(Class)clazz diff --git a/BeeFramework/Foundation/Bee_Sandbox.h b/BeeFramework/Core/Foundation/Bee_Sandbox.h similarity index 100% rename from BeeFramework/Foundation/Bee_Sandbox.h rename to BeeFramework/Core/Foundation/Bee_Sandbox.h diff --git a/BeeFramework/Foundation/Bee_Sandbox.mm b/BeeFramework/Core/Foundation/Bee_Sandbox.mm similarity index 100% rename from BeeFramework/Foundation/Bee_Sandbox.mm rename to BeeFramework/Core/Foundation/Bee_Sandbox.mm diff --git a/BeeFramework/Foundation/Bee_Singleton.h b/BeeFramework/Core/Foundation/Bee_Singleton.h similarity index 100% rename from BeeFramework/Foundation/Bee_Singleton.h rename to BeeFramework/Core/Foundation/Bee_Singleton.h diff --git a/BeeFramework/Foundation/Bee_Singleton.mm b/BeeFramework/Core/Foundation/Bee_Singleton.mm similarity index 100% rename from BeeFramework/Foundation/Bee_Singleton.mm rename to BeeFramework/Core/Foundation/Bee_Singleton.mm diff --git a/BeeFramework/Foundation/Bee_SystemInfo.h b/BeeFramework/Core/Foundation/Bee_SystemInfo.h similarity index 100% rename from BeeFramework/Foundation/Bee_SystemInfo.h rename to BeeFramework/Core/Foundation/Bee_SystemInfo.h diff --git a/BeeFramework/Foundation/Bee_SystemInfo.m b/BeeFramework/Core/Foundation/Bee_SystemInfo.m similarity index 100% rename from BeeFramework/Foundation/Bee_SystemInfo.m rename to BeeFramework/Core/Foundation/Bee_SystemInfo.m diff --git a/BeeFramework/Foundation/Bee_Thread.h b/BeeFramework/Core/Foundation/Bee_Thread.h similarity index 100% rename from BeeFramework/Foundation/Bee_Thread.h rename to BeeFramework/Core/Foundation/Bee_Thread.h diff --git a/BeeFramework/Foundation/Bee_Thread.mm b/BeeFramework/Core/Foundation/Bee_Thread.mm similarity index 100% rename from BeeFramework/Foundation/Bee_Thread.mm rename to BeeFramework/Core/Foundation/Bee_Thread.mm diff --git a/BeeFramework/Foundation/NSArray+BeeExtension.h b/BeeFramework/Core/Foundation/Extension/NSArray+BeeExtension.h similarity index 91% rename from BeeFramework/Foundation/NSArray+BeeExtension.h rename to BeeFramework/Core/Foundation/Extension/NSArray+BeeExtension.h index bddfcba..1e419c1 100644 --- a/BeeFramework/Foundation/NSArray+BeeExtension.h +++ b/BeeFramework/Core/Foundation/Extension/NSArray+BeeExtension.h @@ -34,8 +34,14 @@ #pragma mark - +typedef NSArray * (^NSMutableArrayAppendBlock)( id obj ); + +#pragma mark - + @interface NSArray(BeeExtension) +@property (nonatomic, readonly) NSMutableArrayAppendBlock APPEND; + - (NSArray *)head:(NSUInteger)count; - (NSArray *)tail:(NSUInteger)count; @@ -47,6 +53,8 @@ @interface NSMutableArray(BeeExtension) ++ (NSMutableArray *)nonRetainingArray; // copy from Three20 + - (NSMutableArray *)pushHead:(NSObject *)obj; - (NSMutableArray *)pushHeadN:(NSArray *)all; - (NSMutableArray *)popTail; diff --git a/BeeFramework/Foundation/NSArray+BeeExtension.m b/BeeFramework/Core/Foundation/Extension/NSArray+BeeExtension.m similarity index 81% rename from BeeFramework/Foundation/NSArray+BeeExtension.m rename to BeeFramework/Core/Foundation/Extension/NSArray+BeeExtension.m index ab90982..5b68f40 100644 --- a/BeeFramework/Foundation/NSArray+BeeExtension.m +++ b/BeeFramework/Core/Foundation/Extension/NSArray+BeeExtension.m @@ -33,10 +33,38 @@ #import "Bee_Precompile.h" #import "NSArray+BeeExtension.h" +#include + #pragma mark - @implementation NSArray(BeeExtension) +@dynamic APPEND; + +- (NSMutableArrayAppendBlock)APPEND +{ + NSMutableArrayAppendBlock block = ^ NSArray * ( id obj ) + { + NSString * className = [[self class] description]; + + if ( [className isEqualToString:@"NSMutableArray"] ) + { + [(NSMutableArray *)self addObject:obj]; + return self; + } + else + { + NSMutableArray * array = [NSMutableArray arrayWithArray:self]; + [array addObject:obj]; + return array; + } + + return self; + }; + + return [[block copy] autorelease]; +} + - (NSArray *)head:(NSUInteger)count { if ( [self count] < count ) @@ -74,7 +102,7 @@ - (NSArray *)tail:(NSUInteger)count // return tempFeeds; // } - // thansk @lancy, changed: NSArray tail: count +// thansk @lancy, changed: NSArray tail: count NSRange range = NSMakeRange( self.count - count, count ); return [self subarrayWithRange:range]; @@ -92,8 +120,22 @@ - (id)safeObjectAtIndex:(NSUInteger)index #pragma mark - +// No-ops for non-retaining objects. +static const void * __TTRetainNoOp( CFAllocatorRef allocator, const void * value ) { return value; } +static void __TTReleaseNoOp( CFAllocatorRef allocator, const void * value ) { } + +#pragma mark - + @implementation NSMutableArray(BeeExtension) ++ (NSMutableArray *)nonRetainingArray // copy from Three20 +{ + CFArrayCallBacks callbacks = kCFTypeArrayCallBacks; + callbacks.retain = __TTRetainNoOp; + callbacks.release = __TTReleaseNoOp; + return (NSMutableArray *)CFArrayCreateMutable( nil, 0, &callbacks ); +} + - (NSMutableArray *)pushHead:(NSObject *)obj { if ( obj ) diff --git a/BeeFramework/Foundation/NSData+BeeExtension.h b/BeeFramework/Core/Foundation/Extension/NSData+BeeExtension.h similarity index 89% rename from BeeFramework/Foundation/NSData+BeeExtension.h rename to BeeFramework/Core/Foundation/Extension/NSData+BeeExtension.h index 8fc8c13..7ce5150 100644 --- a/BeeFramework/Foundation/NSData+BeeExtension.h +++ b/BeeFramework/Core/Foundation/Extension/NSData+BeeExtension.h @@ -32,9 +32,13 @@ #import "Bee_Precompile.h" +#pragma mark - + @interface NSData(BeeExtension) -- (NSData *)MD5; -- (NSString *)MD5String; +@property (nonatomic, readonly) NSString * string; + +@property (nonatomic, readonly) NSData * MD5; +@property (nonatomic, readonly) NSString * MD5String; @end diff --git a/BeeFramework/Foundation/NSData+BeeExtension.m b/BeeFramework/Core/Foundation/Extension/NSData+BeeExtension.m similarity index 91% rename from BeeFramework/Foundation/NSData+BeeExtension.m rename to BeeFramework/Core/Foundation/Extension/NSData+BeeExtension.m index a5a1cdf..fa97a74 100644 --- a/BeeFramework/Foundation/NSData+BeeExtension.m +++ b/BeeFramework/Core/Foundation/Extension/NSData+BeeExtension.m @@ -27,7 +27,7 @@ // IN THE SOFTWARE. // // -// NSObject+BeeProperty.m +// NSData+BeeExtension.m // #import @@ -39,6 +39,15 @@ @implementation NSData(BeeExtension) +@dynamic string; +@dynamic MD5; +@dynamic MD5String; + +- (NSString *)string +{ + return [[[NSString alloc] initWithData:self encoding:NSStringEncodingConversionAllowLossy] autorelease]; +} + - (NSData *)MD5 { unsigned char md5Result[CC_MD5_DIGEST_LENGTH + 1]; diff --git a/BeeFramework/Foundation/NSDate+BeeExtension.h b/BeeFramework/Core/Foundation/Extension/NSDate+BeeExtension.h similarity index 93% rename from BeeFramework/Foundation/NSDate+BeeExtension.h rename to BeeFramework/Core/Foundation/Extension/NSDate+BeeExtension.h index d27cdcc..a2b014c 100644 --- a/BeeFramework/Foundation/NSDate+BeeExtension.h +++ b/BeeFramework/Core/Foundation/Extension/NSDate+BeeExtension.h @@ -34,6 +34,9 @@ @interface NSDate(BeeExtension) +@property (nonatomic, readonly) NSString * string; +@property (nonatomic, readonly) NSNumber * number; + - (NSString *)stringWithDateFormat:(NSString *)format; + (NSUInteger)timeStamp; diff --git a/BeeFramework/Foundation/NSDate+BeeExtension.m b/BeeFramework/Core/Foundation/Extension/NSDate+BeeExtension.m similarity index 92% rename from BeeFramework/Foundation/NSDate+BeeExtension.m rename to BeeFramework/Core/Foundation/Extension/NSDate+BeeExtension.m index 035cc8b..6d6b476 100644 --- a/BeeFramework/Foundation/NSDate+BeeExtension.m +++ b/BeeFramework/Core/Foundation/Extension/NSDate+BeeExtension.m @@ -39,6 +39,19 @@ @implementation NSDate(BeeExtension) +@dynamic string; +@dynamic number; + +- (NSString *)string +{ + return self.description; +} + +- (NSNumber *)number +{ + return [NSNumber numberWithDouble:self.timeIntervalSince1970]; +} + - (NSString *)stringWithDateFormat:(NSString *)format { #if 0 diff --git a/BeeFramework/Foundation/NSDictionary+BeeExtension.h b/BeeFramework/Core/Foundation/Extension/NSDictionary+BeeExtension.h similarity index 85% rename from BeeFramework/Foundation/NSDictionary+BeeExtension.h rename to BeeFramework/Core/Foundation/Extension/NSDictionary+BeeExtension.h index f594cac..e8cf2c3 100644 --- a/BeeFramework/Foundation/NSDictionary+BeeExtension.h +++ b/BeeFramework/Core/Foundation/Extension/NSDictionary+BeeExtension.h @@ -34,11 +34,20 @@ #pragma mark - +typedef NSDictionary * (^NSDictionaryAppendBlock)( NSString * key, id value ); + +#pragma mark - + @interface NSDictionary(BeeExtension) +@property (nonatomic, readonly) NSDictionaryAppendBlock APPEND; + - (NSObject *)objectAtPath:(NSString *)path; - (NSObject *)objectAtPath:(NSString *)path otherwise:(NSObject *)other; +- (NSObject *)objectAtPath:(NSString *)path separator:(NSString *)separator; +- (NSObject *)objectAtPath:(NSString *)path otherwise:(NSObject *)other separator:(NSString *)separator; + - (BOOL)boolAtPath:(NSString *)path; - (BOOL)boolAtPath:(NSString *)path otherwise:(BOOL)other; @@ -67,6 +76,8 @@ @interface NSMutableDictionary(BeeExtension) - (BOOL)setObject:(NSObject *)obj atPath:(NSString *)path; +- (BOOL)setObject:(NSObject *)obj atPath:(NSString *)path separator:(NSString *)separator; + - (BOOL)setKeyValues:(id)first, ...; + (NSMutableDictionary *)keyValues:(id)first, ...; diff --git a/BeeFramework/Foundation/NSDictionary+BeeExtension.m b/BeeFramework/Core/Foundation/Extension/NSDictionary+BeeExtension.m similarity index 83% rename from BeeFramework/Foundation/NSDictionary+BeeExtension.m rename to BeeFramework/Core/Foundation/Extension/NSDictionary+BeeExtension.m index 5e79a22..170ec23 100644 --- a/BeeFramework/Foundation/NSDictionary+BeeExtension.m +++ b/BeeFramework/Core/Foundation/Extension/NSDictionary+BeeExtension.m @@ -33,20 +33,55 @@ #import "Bee_Precompile.h" #import "NSDictionary+BeeExtension.h" +#include + #pragma mark - @implementation NSDictionary(BeeExtension) -- (NSObject *)db +- (NSDictionaryAppendBlock)APPEND { - return nil; + NSDictionaryAppendBlock block = ^ NSDictionary * ( NSString * key, id value ) + { + if ( key && value ) + { + NSString * className = [[self class] description]; + + if ( [className isEqualToString:@"NSMutableDictionary"] ) + { + [(NSMutableDictionary *)self setObject:value atPath:key]; + return self; + } + else + { + NSMutableDictionary * dict = [NSMutableDictionary dictionaryWithDictionary:self]; + [dict setObject:value atPath:key]; + return dict; + } + } + + return self; + }; + + return [[block copy] autorelease]; } - (NSObject *)objectAtPath:(NSString *)path { -#if 0 + return [self objectAtPath:path separator:nil]; +} + +- (NSObject *)objectAtPath:(NSString *)path separator:(NSString *)separator +{ + if ( nil == separator ) + { + path = [path stringByReplacingOccurrencesOfString:@"." withString:@"/"]; + separator = @"/"; + } + +#if 1 - NSArray * array = [path componentsSeparatedByString:@"/"]; + NSArray * array = [path componentsSeparatedByString:separator]; if ( 0 == [array count] ) { return nil; @@ -72,7 +107,7 @@ - (NSObject *)objectAtPath:(NSString *)path { return nil; } - + dict = (NSDictionary *)result; } @@ -82,7 +117,7 @@ - (NSObject *)objectAtPath:(NSString *)path // thanks @lancy, changed: use native keyPath - NSString * keyPath = [path stringByReplacingOccurrencesOfString:@"/" withString:@"."]; + NSString * keyPath = [path stringByReplacingOccurrencesOfString:separator withString:@"."]; NSRange range = NSMakeRange( 0, 1 ); if ( [[keyPath substringWithRange:range] isEqualToString:@"."] ) @@ -102,6 +137,12 @@ - (NSObject *)objectAtPath:(NSString *)path otherwise:(NSObject *)other return obj ? obj : other; } +- (NSObject *)objectAtPath:(NSString *)path otherwise:(NSObject *)other separator:(NSString *)separator +{ + NSObject * obj = [self objectAtPath:path separator:separator]; + return obj ? obj : other; +} + - (BOOL)boolAtPath:(NSString *)path { return [self boolAtPath:path otherwise:NO]; @@ -240,14 +281,25 @@ - (NSMutableDictionary *)mutableDictAtPath:(NSString *)path otherwise:(NSMutable #pragma mark - -@implementation NSMutableDictionary(Bee_XPath) +@implementation NSMutableDictionary(BeeExtension) - (BOOL)setObject:(NSObject *)obj atPath:(NSString *)path +{ + return [self setObject:obj atPath:path separator:nil]; +} + +- (BOOL)setObject:(NSObject *)obj atPath:(NSString *)path separator:(NSString *)separator { if ( 0 == [path length] ) return NO; - NSArray * array = [path componentsSeparatedByString:@"/"]; + if ( nil == separator ) + { + path = [path stringByReplacingOccurrencesOfString:@"." withString:@"/"]; + separator = @"/"; + } + + NSArray * array = [path componentsSeparatedByString:separator]; if ( 0 == [array count] ) { [self setObject:obj forKey:path]; diff --git a/BeeFramework/Foundation/NSNumber+BeeExtension.h b/BeeFramework/Core/Foundation/Extension/NSNumber+BeeExtension.h similarity index 96% rename from BeeFramework/Foundation/NSNumber+BeeExtension.h rename to BeeFramework/Core/Foundation/Extension/NSNumber+BeeExtension.h index f935a61..ac25fd5 100644 --- a/BeeFramework/Foundation/NSNumber+BeeExtension.h +++ b/BeeFramework/Core/Foundation/Extension/NSNumber+BeeExtension.h @@ -32,22 +32,19 @@ #import "Bee_Precompile.h" -#undef __INT -#define __INT( __x ) [NSNumber numberWithInt:(NSInteger)__x] +#pragma mark - -#undef __UINT +#define __INT( __x ) [NSNumber numberWithInt:(NSInteger)__x] #define __UINT( __x ) [NSNumber numberWithUnsignedInt:(NSUInteger)__x] - -#undef __FLOAT #define __FLOAT( __x ) [NSNumber numberWithFloat:(float)__x] - -#undef __DOUBLE #define __DOUBLE( __x ) [NSNumber numberWithDouble:(double)__x] #pragma mark - @interface NSNumber(BeeExtension) +@property (nonatomic, readonly) NSDate * date; + - (NSString *)stringWithDateFormat:(NSString *)format; @end diff --git a/BeeFramework/Foundation/NSNumber+BeeExtension.m b/BeeFramework/Core/Foundation/Extension/NSNumber+BeeExtension.m similarity index 95% rename from BeeFramework/Foundation/NSNumber+BeeExtension.m rename to BeeFramework/Core/Foundation/Extension/NSNumber+BeeExtension.m index 7783883..502a333 100644 --- a/BeeFramework/Foundation/NSNumber+BeeExtension.m +++ b/BeeFramework/Core/Foundation/Extension/NSNumber+BeeExtension.m @@ -35,6 +35,13 @@ @implementation NSNumber(BeeExtension) +@dynamic date; + +- (NSDate *)date +{ + return [NSDate dateWithTimeIntervalSince1970:self.doubleValue]; +} + - (NSString *)stringWithDateFormat:(NSString *)format { #if 0 diff --git a/BeeFramework/Foundation/NSObject+BeeNotification.h b/BeeFramework/Core/Foundation/Extension/NSObject+BeeNotification.h similarity index 98% rename from BeeFramework/Foundation/NSObject+BeeNotification.h rename to BeeFramework/Core/Foundation/Extension/NSObject+BeeNotification.h index 1fa1d23..b7415c5 100644 --- a/BeeFramework/Foundation/NSObject+BeeNotification.h +++ b/BeeFramework/Core/Foundation/Extension/NSObject+BeeNotification.h @@ -52,6 +52,7 @@ @interface NSObject(BeeNotification) + (NSString *)NOTIFICATION; ++ (NSString *)NOTIFICATION_TYPE; - (void)handleNotification:(NSNotification *)notification; diff --git a/BeeFramework/Foundation/NSObject+BeeNotification.m b/BeeFramework/Core/Foundation/Extension/NSObject+BeeNotification.m similarity index 65% rename from BeeFramework/Foundation/NSObject+BeeNotification.m rename to BeeFramework/Core/Foundation/Extension/NSObject+BeeNotification.m index f5512e5..7e6864d 100644 --- a/BeeFramework/Foundation/NSObject+BeeNotification.m +++ b/BeeFramework/Core/Foundation/Extension/NSObject+BeeNotification.m @@ -52,13 +52,14 @@ - (BOOL)isKindOf:(NSString *)prefix #pragma mark - -@interface NSObject(BeeNotificationPrivate) -- (void)handleNSNotification:(NSNotification *)n; -@end - @implementation NSObject(BeeNotification) + (NSString *)NOTIFICATION +{ + return [self NOTIFICATION_TYPE]; +} + ++ (NSString *)NOTIFICATION_TYPE { return [NSString stringWithFormat:@"notify.%@.", [self description]]; } @@ -69,6 +70,51 @@ - (void)handleNotification:(NSNotification *)notification - (void)observeNotification:(NSString *)name { + NSArray * array = [name componentsSeparatedByString:@"."]; + if ( array && array.count > 1 ) + { +// NSString * prefix = (NSString *)[array objectAtIndex:0]; + NSString * clazz = (NSString *)[array objectAtIndex:1]; + NSString * name = (NSString *)[array objectAtIndex:2]; + + #if defined(__BEE_SELECTOR_STYLE2__) && __BEE_SELECTOR_STYLE2__ + { + NSString * selectorName; + SEL selector; + + selectorName = [NSString stringWithFormat:@"handleNotification_%@_%@:", clazz, name]; + selector = NSSelectorFromString(selectorName); + + if ( [self respondsToSelector:selector] ) + { + [[NSNotificationCenter defaultCenter] addObserver:self + selector:selector + name:name + object:nil]; + return; + } + + selectorName = [NSString stringWithFormat:@"handleNotification_%@:", clazz]; + selector = NSSelectorFromString(selectorName); + + if ( [self respondsToSelector:selector] ) + { + [[NSNotificationCenter defaultCenter] addObserver:self + selector:selector + name:name + object:nil]; + return; + } + } + #endif // #if defined(__BEE_SMART_SELECTOR2__) && __BEE_SMART_SELECTOR2__ + + #if defined(__BEE_SELECTOR_STYLE1__) && __BEE_SELECTOR_STYLE1__ + { + // TODO: + } + #endif // #if defined(__BEE_SMART_SELECTOR1__) && __BEE_SMART_SELECTOR1__ + } + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleNotification:) name:name diff --git a/BeeFramework/Foundation/NSObject+BeeProperty.h b/BeeFramework/Core/Foundation/Extension/NSObject+BeeProperty.h similarity index 100% rename from BeeFramework/Foundation/NSObject+BeeProperty.h rename to BeeFramework/Core/Foundation/Extension/NSObject+BeeProperty.h diff --git a/BeeFramework/Foundation/NSObject+BeeProperty.m b/BeeFramework/Core/Foundation/Extension/NSObject+BeeProperty.m similarity index 100% rename from BeeFramework/Foundation/NSObject+BeeProperty.m rename to BeeFramework/Core/Foundation/Extension/NSObject+BeeProperty.m diff --git a/BeeFramework/Foundation/NSObject+BeeTicker.h b/BeeFramework/Core/Foundation/Extension/NSObject+BeeTicker.h similarity index 100% rename from BeeFramework/Foundation/NSObject+BeeTicker.h rename to BeeFramework/Core/Foundation/Extension/NSObject+BeeTicker.h diff --git a/BeeFramework/Foundation/NSObject+BeeTicker.m b/BeeFramework/Core/Foundation/Extension/NSObject+BeeTicker.m similarity index 95% rename from BeeFramework/Foundation/NSObject+BeeTicker.m rename to BeeFramework/Core/Foundation/Extension/NSObject+BeeTicker.m index 38ae351..6a3f97a 100644 --- a/BeeFramework/Foundation/NSObject+BeeTicker.m +++ b/BeeFramework/Core/Foundation/Extension/NSObject+BeeTicker.m @@ -70,7 +70,7 @@ - (id)init self = [super init]; if ( self ) { - _receives = [[NSMutableArray alloc] init]; + _receives = [NSMutableArray nonRetainingArray]; } return self; @@ -80,7 +80,7 @@ - (void)addReceive:(NSObject *)obj { if ( NO == [_receives containsObject:obj] ) { - [_receives addObjectNoRetain:obj]; + [_receives addObject:obj]; if ( nil == _timer ) { @@ -97,7 +97,7 @@ - (void)addReceive:(NSObject *)obj - (void)removeReceive:(NSObject *)obj { - [_receives removeObjectNoRelease:obj]; + [_receives removeObject:obj]; if ( 0 == _receives.count ) { @@ -127,7 +127,7 @@ - (void)dealloc [_timer invalidate]; _timer = nil; - [_receives removeAllObjectsNoRelease]; + [_receives removeAllObjects]; [_receives release]; [super dealloc]; diff --git a/BeeFramework/Core/Foundation/Extension/NSObject+BeeTypeConversion.h b/BeeFramework/Core/Foundation/Extension/NSObject+BeeTypeConversion.h new file mode 100644 index 0000000..db41764 --- /dev/null +++ b/BeeFramework/Core/Foundation/Extension/NSObject+BeeTypeConversion.h @@ -0,0 +1,49 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// NSObject+BeeTicker.h +// + +#import "Bee_Precompile.h" + +#pragma mark - + +@interface NSObject(BeeTypeConversion) + +- (BOOL)isNotKindOfClass:(Class)aClass; + +- (NSNumber *)asNSNumber; +- (NSString *)asNSString; +- (NSDate *)asNSDate; + +//- (NSData *)asNSData; +//- (NSArray *)asNSArray; +//- (NSDictionary *)asNSDictionary; + +@end diff --git a/BeeFramework/Core/Foundation/Extension/NSObject+BeeTypeConversion.m b/BeeFramework/Core/Foundation/Extension/NSObject+BeeTypeConversion.m new file mode 100644 index 0000000..c5855a1 --- /dev/null +++ b/BeeFramework/Core/Foundation/Extension/NSObject+BeeTypeConversion.m @@ -0,0 +1,109 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// NSObject+BeeTicker.m +// + +#import "Bee_Precompile.h" +#import "Bee_Singleton.h" +#import "NSObject+BeeTypeConversion.h" +#import "NSArray+BeeExtension.h" + +#pragma mark - + +@implementation NSObject(BeeTypeConversion) + +- (BOOL)isNotKindOfClass:(Class)aClass +{ + return NO == [self isKindOfClass:aClass]; +} + +- (NSNumber *)asNSNumber +{ + if ( [self isKindOfClass:[NSNumber class]] ) + { + return (NSNumber *)self; + } + else if ( [self isKindOfClass:[NSString class]] ) + { + return [NSNumber numberWithInteger:[(NSString *)self integerValue]]; + } + else if ( [self isKindOfClass:[NSDate class]] ) + { + return [NSNumber numberWithDouble:[(NSDate *)self timeIntervalSince1970]]; + } + else if ( [self isKindOfClass:[NSNull class]] ) + { + return [NSNumber numberWithInteger:0]; + } + + return nil; +} + +- (NSString *)asNSString +{ + if ( [self isKindOfClass:[NSString class]] ) + { + return (NSString *)self; + } + else + { + return [NSString stringWithFormat:@"%@", self]; + } +} + +- (NSDate *)asNSDate +{ + if ( [self isKindOfClass:[NSDate class]] ) + { + return (NSDate *)self; + } + else if ( [self isKindOfClass:[NSString class]] ) + { + NSTimeZone * local = [NSTimeZone localTimeZone]; + + NSString * format = @"yyyy-MM-dd HH:mm:ss"; + NSString * text = [(NSString *)self substringToIndex:format.length]; + + NSDateFormatter * dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; + [dateFormatter setDateFormat:format]; + [dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]]; + + return [NSDate dateWithTimeInterval:(3600 + [local secondsFromGMT]) + sinceDate:[dateFormatter dateFromString:text]]; + } + else + { + return [NSDate dateWithTimeIntervalSince1970:[self asNSNumber].doubleValue]; + } + + return nil; +} + +@end diff --git a/BeeFramework/Foundation/NSString+BeeExtension.h b/BeeFramework/Core/Foundation/Extension/NSString+BeeExtension.h similarity index 77% rename from BeeFramework/Foundation/NSString+BeeExtension.h rename to BeeFramework/Core/Foundation/Extension/NSString+BeeExtension.h index 808ee05..41df93e 100644 --- a/BeeFramework/Foundation/NSString+BeeExtension.h +++ b/BeeFramework/Core/Foundation/Extension/NSString+BeeExtension.h @@ -34,28 +34,40 @@ #pragma mark - +typedef NSString * (^NSStringAppendBlock)( id format, ... ); + +#pragma mark - + @interface NSString(BeeExtension) +@property (nonatomic, readonly) NSStringAppendBlock APPEND; + +@property (nonatomic, readonly) NSData * data; +@property (nonatomic, readonly) NSDate * date; + +@property (nonatomic, readonly) NSString * MD5; +@property (nonatomic, readonly) NSData * MD5Data; + - (NSArray *)allURLs; - (NSString *)urlByAppendingDict:(NSDictionary *)params; - (NSString *)urlByAppendingArray:(NSArray *)params; - (NSString *)urlByAppendingKeyValues:(id)first, ...; -- (NSString *)queryStringFromDictionary:(NSDictionary *)dict; -- (NSString *)queryStringFromArray:(NSArray *)array; -- (NSString *)queryStringFromKeyValues:(id)first, ...; ++ (NSString *)queryStringFromDictionary:(NSDictionary *)dict; ++ (NSString *)queryStringFromArray:(NSArray *)array; ++ (NSString *)queryStringFromKeyValues:(id)first, ...; - (NSString *)URLEncoding; - (NSString *)URLDecoding; -- (NSString *)MD5; - (NSString *)trim; - (BOOL)empty; - (BOOL)notEmpty; - (BOOL)is:(NSString *)other; +- (BOOL)isNot:(NSString *)other; - (BOOL)isValueOf:(NSArray *)array; - (BOOL)isValueOf:(NSArray *)array caseInsens:(BOOL)caseInsens; diff --git a/BeeFramework/Foundation/NSString+BeeExtension.m b/BeeFramework/Core/Foundation/Extension/NSString+BeeExtension.m similarity index 78% rename from BeeFramework/Foundation/NSString+BeeExtension.m rename to BeeFramework/Core/Foundation/Extension/NSString+BeeExtension.m index 871ca4a..081f20a 100644 --- a/BeeFramework/Foundation/NSString+BeeExtension.m +++ b/BeeFramework/Core/Foundation/Extension/NSString+BeeExtension.m @@ -33,11 +33,75 @@ #import "Bee_Precompile.h" #import "NSString+BeeExtension.h" #import "NSData+BeeExtension.h" +#import "NSObject+BeeTypeConversion.h" + +#include #pragma mark - @implementation NSString(BeeExtension) +@dynamic data; +@dynamic date; + +@dynamic MD5; +@dynamic MD5Data; + +@dynamic APPEND; + +- (NSData *)data +{ + return [self dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]; +} + +- (NSDate *)date +{ + NSTimeZone * local = [NSTimeZone localTimeZone]; + + NSString * format = @"yyyy-MM-dd HH:mm:ss"; + NSString * text = [(NSString *)self substringToIndex:format.length]; + + NSDateFormatter * dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; + [dateFormatter setDateFormat:format]; + [dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]]; + + return [NSDate dateWithTimeInterval:(3600 + [local secondsFromGMT]) + sinceDate:[dateFormatter dateFromString:text]]; + +} + +- (NSStringAppendBlock)APPEND +{ + NSStringAppendBlock block = ^ NSString * ( id first, ... ) + { + va_list args; + va_start( args, first ); + + NSString * className = [[self class] description]; + + if ( [className isEqualToString:@"NSMutableString"] ) + { + NSString * append = [[NSString alloc] initWithFormat:first arguments:args]; + [(NSMutableString *)self appendString:append]; + [append release]; + + return self; + } + else + { + NSMutableString * copy = [self mutableCopy]; + + NSString * append = [[NSString alloc] initWithFormat:first arguments:args]; + [copy appendString:append]; + [append release]; + + return [copy autorelease]; + } + }; + + return [[block copy] autorelease]; +} + - (NSArray *)allURLs { NSMutableArray * array = [NSMutableArray array]; @@ -98,17 +162,12 @@ - (NSArray *)allURLs return array; } -- (NSString *)queryStringFromDictionary:(NSDictionary *)dict ++ (NSString *)queryStringFromDictionary:(NSDictionary *)dict { NSMutableArray * pairs = [NSMutableArray array]; - for ( NSString * key in [dict keyEnumerator] ) + for ( NSString * key in dict.allKeys ) { - if ( !([[dict valueForKey:key] isKindOfClass:[NSString class]]) ) - { - continue; - } - - NSString * value = [dict objectForKey:key]; + NSString * value = [((NSObject *)[dict objectForKey:key]) asNSString]; NSString * urlEncoding = [value URLEncoding]; [pairs addObject:[NSString stringWithFormat:@"%@=%@", key, urlEncoding]]; } @@ -116,15 +175,7 @@ - (NSString *)queryStringFromDictionary:(NSDictionary *)dict return [pairs componentsJoinedByString:@"&"]; } -- (NSString *)urlByAppendingDict:(NSDictionary *)params -{ - NSURL * parsedURL = [NSURL URLWithString:self]; - NSString * queryPrefix = parsedURL.query ? @"&" : @"?"; - NSString * query = [self queryStringFromDictionary:params]; - return [NSString stringWithFormat:@"%@%@%@", self, queryPrefix, query]; -} - -- (NSString *)queryStringFromArray:(NSArray *)array ++ (NSString *)queryStringFromArray:(NSArray *)array { NSMutableArray *pairs = [NSMutableArray array]; @@ -163,21 +214,13 @@ - (NSString *)queryStringFromArray:(NSArray *)array } NSString * urlEncoding = [value URLEncoding]; - [pairs addObject:[NSString stringWithFormat:@"%@=%@", key, urlEncoding]]; + [pairs addObject:[NSString stringWithFormat:@"%@=%@", key, urlEncoding]]; } return [pairs componentsJoinedByString:@"&"]; } -- (NSString *)urlByAppendingArray:(NSArray *)params -{ - NSURL * parsedURL = [NSURL URLWithString:self]; - NSString * queryPrefix = parsedURL.query ? @"&" : @"?"; - NSString * query = [self queryStringFromArray:params]; - return [NSString stringWithFormat:@"%@%@%@", self, queryPrefix, query]; -} - -- (NSString *)urlByAppendingKeyValues:(id)first, ... ++ (NSString *)queryStringFromKeyValues:(id)first, ... { NSMutableDictionary * dict = [NSMutableDictionary dictionary]; @@ -193,14 +236,30 @@ - (NSString *)urlByAppendingKeyValues:(id)first, ... NSObject * value = va_arg( args, NSObject * ); if ( nil == value ) break; - + [dict setObject:value forKey:key]; } + + return [NSString queryStringFromDictionary:dict]; +} - return [self urlByAppendingDict:dict]; +- (NSString *)urlByAppendingDict:(NSDictionary *)params +{ + NSURL * parsedURL = [NSURL URLWithString:self]; + NSString * queryPrefix = parsedURL.query ? @"&" : @"?"; + NSString * query = [NSString queryStringFromDictionary:params]; + return [NSString stringWithFormat:@"%@%@%@", self, queryPrefix, query]; +} + +- (NSString *)urlByAppendingArray:(NSArray *)params +{ + NSURL * parsedURL = [NSURL URLWithString:self]; + NSString * queryPrefix = parsedURL.query ? @"&" : @"?"; + NSString * query = [NSString queryStringFromArray:params]; + return [NSString stringWithFormat:@"%@%@%@", self, queryPrefix, query]; } -- (NSString *)queryStringFromKeyValues:(id)first, ... +- (NSString *)urlByAppendingKeyValues:(id)first, ... { NSMutableDictionary * dict = [NSMutableDictionary dictionary]; @@ -216,11 +275,11 @@ - (NSString *)queryStringFromKeyValues:(id)first, ... NSObject * value = va_arg( args, NSObject * ); if ( nil == value ) break; - + [dict setObject:value forKey:key]; } - return [self queryStringFromDictionary:dict]; + return [self urlByAppendingDict:dict]; } - (BOOL)empty @@ -238,6 +297,11 @@ - (BOOL)is:(NSString *)other return [self isEqualToString:other]; } +- (BOOL)isNot:(NSString *)other +{ + return NO == [self isEqualToString:other]; +} + - (BOOL)isValueOf:(NSArray *)array { return [self isValueOf:array caseInsens:NO]; @@ -311,6 +375,12 @@ - (NSString *)MD5 } } +- (NSData *)MD5Data +{ + // TODO: + return nil; +} + - (NSString *)trim { return [self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; diff --git a/BeeFramework/Core/Network/Bee_Network.h b/BeeFramework/Core/Network/Bee_Network.h new file mode 100644 index 0000000..8d4f91f --- /dev/null +++ b/BeeFramework/Core/Network/Bee_Network.h @@ -0,0 +1,36 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_Network.h +// + +#import "Bee_Request.h" +#import "Bee_Request.h" +#import "Bee_RequestQueue.h" +#import "NSObject+BeeRequest.h" diff --git a/BeeFramework/Core/Network/Bee_Network.m b/BeeFramework/Core/Network/Bee_Network.m new file mode 100644 index 0000000..c758a29 --- /dev/null +++ b/BeeFramework/Core/Network/Bee_Network.m @@ -0,0 +1,33 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_Network.m +// + +#import "Bee_Network.h" diff --git a/BeeFramework/Foundation/Bee_Network.h b/BeeFramework/Core/Network/Bee_Request.h similarity index 61% rename from BeeFramework/Foundation/Bee_Network.h rename to BeeFramework/Core/Network/Bee_Request.h index 77fc6cf..2bf92cb 100644 --- a/BeeFramework/Foundation/Bee_Network.h +++ b/BeeFramework/Core/Network/Bee_Request.h @@ -27,7 +27,7 @@ // IN THE SOFTWARE. // // -// Bee_Network.h +// Bee_Request.h // #import "Bee_Precompile.h" @@ -45,36 +45,10 @@ #pragma mark - -@interface NSObject(BeeRequestResponder) - -- (BOOL)isRequestResponder; - -- (BeeRequest *)GET:(NSString *)url; -- (BeeRequest *)POST:(NSString *)url data:(NSData *)data; -- (BeeRequest *)POST:(NSString *)url text:(NSString *)text; -- (BeeRequest *)POST:(NSString *)url dict:(NSDictionary *)kvs; -- (BeeRequest *)POST:(NSString *)url params:(id)first, ...; -- (BeeRequest *)POST:(NSString *)url files:(NSDictionary *)files; -- (BeeRequest *)POST:(NSString *)url files:(NSDictionary *)files dict:(NSDictionary *)kvs; -- (BeeRequest *)POST:(NSString *)url files:(NSDictionary *)files params:(id)first, ...; - -- (BOOL)requestingURL; -- (BOOL)requestingURL:(NSString *)url; - -- (NSArray *)requests; -- (NSArray *)requests:(NSString *)url; - -- (void)cancelRequests; - -- (void)handleRequest:(BeeRequest *)request; - -@end - -#pragma mark - - -#pragma mark - - -typedef void (^BeeRequestBlock)( BeeRequest * req ); +typedef void (^BeeRequestBlock)( BeeRequest * req ); +typedef BeeRequest * (^BeeRequestBlockV)( void ); +typedef BeeRequest * (^BeeRequestBlockN)( id key, ... ); +typedef BeeRequest * (^BeeRequestBlockS)( NSString * string ); #pragma mark - @@ -108,6 +82,11 @@ AS_INT( STATE_FAILED ); AS_INT( STATE_SUCCEED ); AS_INT( STATE_CANCELLED ); +@property (nonatomic, readonly) BeeRequestBlockN HEADER; // directly set header +@property (nonatomic, readonly) BeeRequestBlockN BODY; // directly set body +@property (nonatomic, readonly) BeeRequestBlockN PARAM; // add key value +@property (nonatomic, readonly) BeeRequestBlockN FILE; // add file data + @property (nonatomic, assign) NSUInteger state; @property (nonatomic, retain) NSMutableArray * responders; //@property (nonatomic, assign) id responder; @@ -159,70 +138,7 @@ AS_INT( STATE_CANCELLED ); - (void)callResponders; - (void)forwardResponder:(NSObject *)obj; -@end - -#pragma mark - - -@interface BeeRequestQueue : NSObject -{ - BOOL _merge; - BOOL _online; - - BOOL _blackListEnable; - NSTimeInterval _blackListTimeout; - NSMutableDictionary * _blackList; - - NSUInteger _bytesUpload; - NSUInteger _bytesDownload; - - NSTimeInterval _delay; - NSMutableArray * _requests; - - BeeRequestBlock _whenCreate; - BeeRequestBlock _whenUpdate; -} - -@property (nonatomic, assign) BOOL merge; -@property (nonatomic, assign) BOOL online; // 开网/断网 - -@property (nonatomic, assign) BOOL blackListEnable; // 是否使用黑名单 -@property (nonatomic, assign) NSTimeInterval blackListTimeout; // 黑名单超时 -@property (nonatomic, retain) NSMutableDictionary * blackList; - -@property (nonatomic, assign) NSUInteger bytesUpload; -@property (nonatomic, assign) NSUInteger bytesDownload; - -@property (nonatomic, assign) NSTimeInterval delay; -@property (nonatomic, retain) NSMutableArray * requests; - -@property (nonatomic, copy) BeeRequestBlock whenCreate; -@property (nonatomic, copy) BeeRequestBlock whenUpdate; - -+ (BeeRequestQueue *)sharedInstance; - -+ (BOOL)isReachableViaWIFI; -+ (BOOL)isReachableViaWLAN; -+ (BOOL)isNetworkInUse; -+ (NSUInteger)bandwidthUsedPerSecond; - -+ (BeeRequest *)GET:(NSString *)url; -+ (BeeRequest *)POST:(NSString *)url data:(NSData *)data; -+ (BeeRequest *)POST:(NSString *)url params:(NSDictionary *)kvs; -+ (BeeRequest *)POST:(NSString *)url files:(NSDictionary *)files; -+ (BeeRequest *)POST:(NSString *)url files:(NSDictionary *)files params:(NSDictionary *)kvs; - -+ (BOOL)requesting:(NSString *)url; -+ (BOOL)requesting:(NSString *)url byResponder:(id)responder; - -+ (NSArray *)requests:(NSString *)url; -+ (NSArray *)requests:(NSString *)url byResponder:(id)responder; - -+ (void)cancelRequest:(BeeRequest *)request; -+ (void)cancelRequestByResponder:(id)responder; -+ (void)cancelAllRequests; - -+ (void)blockURL:(NSString *)url; -+ (void)unblockURL:(NSString *)url; +- (void)updateSendProgress; +- (void)updateRecvProgress; @end - diff --git a/BeeFramework/Core/Network/Bee_Request.m b/BeeFramework/Core/Network/Bee_Request.m new file mode 100644 index 0000000..3287476 --- /dev/null +++ b/BeeFramework/Core/Network/Bee_Request.m @@ -0,0 +1,561 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_Request.m +// + +#include + +#import "Bee_Precompile.h" +#import "Bee_Network.h" +#import "Bee_Runtime.h" +#import "Bee_Log.h" + +#import "NSArray+BeeExtension.h" +#import "NSString+BeeExtension.h" +#import "NSDictionary+BeeExtension.h" +#import "NSObject+BeeTypeConversion.h" + +#import "ASIHTTPRequest.h" +#import "ASIDataDecompressor.h" +#import "ASIFormDataRequest.h" + +#pragma mark - + +@interface BeeRequest(Private) +- (void)updateSendProgress; +- (void)updateRecvProgress; +@end + +#pragma mark - + +@implementation BeeRequest + +DEF_INT( STATE_CREATED, 0 ); +DEF_INT( STATE_SENDING, 1 ); +DEF_INT( STATE_RECVING, 2 ); +DEF_INT( STATE_FAILED, 3 ); +DEF_INT( STATE_SUCCEED, 4 ); +DEF_INT( STATE_CANCELLED, 5 ); + +@dynamic HEADER; +@dynamic BODY; +@dynamic PARAM; +@dynamic FILE; + +@synthesize state = _state; +@synthesize errorCode = _errorCode; +//@synthesize responder = _responder; +@synthesize responders = _responders; +@synthesize userInfo = _userInfo; + +@synthesize whenUpdate = _whenUpdate; + +@synthesize initTimeStamp = _initTimeStamp; +@synthesize sendTimeStamp = _sendTimeStamp; +@synthesize recvTimeStamp = _recvTimeStamp; +@synthesize doneTimeStamp = _doneTimeStamp; + +@synthesize timeCostPending; // 排队等待耗时 +@synthesize timeCostOverDNS; // 网络连接耗时(DNS) +@synthesize timeCostRecving; // 网络收包耗时 +@synthesize timeCostOverAir; // 网络整体耗时 + +#if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ +@synthesize callstack = _callstack; +#endif // #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ + +@synthesize created; +@synthesize sending; +@synthesize recving; +@synthesize failed; +@synthesize succeed; +//@synthesize cancelled; +@synthesize sendProgressed = _sendProgressed; +@synthesize recvProgressed = _recvProgressed; + +@synthesize uploadPercent; +@synthesize uploadBytes; +@synthesize uploadTotalBytes; +@synthesize downloadPercent; +@synthesize downloadBytes; +@synthesize downloadTotalBytes; + +- (id)initWithURL:(NSURL *)newURL +{ + self = [super initWithURL:newURL]; + if ( self ) + { + _state = BeeRequest.STATE_CREATED; + _errorCode = 0; + + _responders = [NSMutableArray nonRetainingArray]; + _userInfo = [[NSMutableDictionary alloc] init]; + + _whenUpdate = nil; + + _sendProgressed = NO; + _recvProgressed = NO; + + _initTimeStamp = [NSDate timeIntervalSinceReferenceDate]; + _sendTimeStamp = _initTimeStamp; + _recvTimeStamp = _initTimeStamp; + _doneTimeStamp = _initTimeStamp; + + #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ + _callstack = [[NSMutableArray alloc] init]; + [_callstack addObjectsFromArray:[BeeRuntime callstack:16]]; + #endif // #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ + } + + return self; +} + +- (NSString *)description +{ + return [NSString stringWithFormat:@"%@ %@, state ==> %d, %d/%d", + self.requestMethod, [self.url absoluteString], + self.state, + [self uploadBytes], [self downloadBytes]]; +} + +- (void)dealloc +{ + self.whenUpdate = nil; + + [_responders removeAllObjects]; + [_responders release]; + _responders = nil; + + [_userInfo removeAllObjects]; + [_userInfo release]; + _userInfo = nil; + +#if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ + [_callstack removeAllObjects]; + [_callstack release]; + _callstack = nil; +#endif // #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ + + [super dealloc]; +} + +- (CGFloat)uploadPercent +{ + NSUInteger bytes1 = self.uploadBytes; + NSUInteger bytes2 = self.uploadTotalBytes; + + return bytes2 ? ((CGFloat)bytes1 / (CGFloat)bytes2) : 0.0f; +} + +- (NSUInteger)uploadBytes +{ + if ( [self.requestMethod isEqualToString:@"GET"] ) + { + return 0; + } + else if ( [self.requestMethod isEqualToString:@"POST"] ) + { + return self.postLength; + } + + return 0; +} + +- (NSUInteger)uploadTotalBytes +{ + if ( [self.requestMethod isEqualToString:@"GET"] ) + { + return 0; + } + else if ( [self.requestMethod isEqualToString:@"POST"] ) + { + return self.postLength; + } + + return 0; +} + +- (CGFloat)downloadPercent +{ + NSUInteger bytes1 = self.downloadBytes; + NSUInteger bytes2 = self.downloadTotalBytes; + + return bytes2 ? ((CGFloat)bytes1 / (CGFloat)bytes2) : 0.0f; +} + +- (NSUInteger)downloadBytes +{ + return [[self rawResponseData] length]; +} + +- (NSUInteger)downloadTotalBytes +{ + return self.contentLength; +} + +- (BOOL)is:(NSString *)text +{ + return [[self.url absoluteString] isEqualToString:text]; +} + +- (void)callResponders +{ + NSArray * responds = [self.responders copy]; + + for ( NSObject * responder in responds) + { + if ( [responder isRequestResponder] ) + { + [responder handleRequest:self]; + } + } + + [responds release]; +} + +- (void)forwardResponder:(NSObject *)obj +{ + if ( [obj isRequestResponder] ) + { + [obj handleRequest:self]; + } +} + +- (void)changeState:(NSUInteger)state +{ + if ( state != _state ) + { + _state = state; + + if ( BeeRequest.STATE_SENDING == _state ) + { + _sendTimeStamp = [NSDate timeIntervalSinceReferenceDate]; + } + else if ( BeeRequest.STATE_RECVING == _state ) + { + _recvTimeStamp = [NSDate timeIntervalSinceReferenceDate]; + } + else if ( BeeRequest.STATE_FAILED == _state || BeeRequest.STATE_SUCCEED == _state || BeeRequest.STATE_CANCELLED == _state ) + { + _doneTimeStamp = [NSDate timeIntervalSinceReferenceDate]; + } + + [self callResponders]; + +// if ( [_responder isRequestResponder] ) +// { +// [_responder handleRequest:self]; +// } + + if ( self.whenUpdate ) + { + self.whenUpdate( self ); + } + } +} + +- (void)updateSendProgress +{ + _sendProgressed = YES; + + [self callResponders]; + +// if ( [_responder isRequestResponder] ) +// { +// [_responder handleRequest:self]; +// } + + if ( self.whenUpdate ) + { + self.whenUpdate( self ); + } + + _sendProgressed = NO; +} + +- (void)updateRecvProgress +{ + if ( _state == BeeRequest.STATE_SUCCEED || _state == BeeRequest.STATE_FAILED || _state == BeeRequest.STATE_CANCELLED ) + return; + + if ( self.didUseCachedResponse ) + return; + + _recvProgressed = YES; + + [self callResponders]; + +// if ( [_responder isRequestResponder] ) +// { +// [_responder handleRequest:self]; +// } + + if ( self.whenUpdate ) + { + self.whenUpdate( self ); + } + + _recvProgressed = NO; +} + +- (NSTimeInterval)timeCostPending +{ + return _sendTimeStamp - _initTimeStamp; +} + +- (NSTimeInterval)timeCostOverDNS +{ + return _recvTimeStamp - _sendTimeStamp; +} + +- (NSTimeInterval)timeCostRecving +{ + return _doneTimeStamp - _recvTimeStamp; +} + +- (NSTimeInterval)timeCostOverAir +{ + return _doneTimeStamp - _sendTimeStamp; +} + +- (BOOL)created +{ + return BeeRequest.STATE_CREATED == _state ? YES : NO; +} + +- (BOOL)sending +{ + return BeeRequest.STATE_SENDING == _state ? YES : NO; +} + +- (BOOL)recving +{ + return BeeRequest.STATE_RECVING == _state ? YES : NO; +} + +- (BOOL)succeed +{ + return BeeRequest.STATE_SUCCEED == _state ? YES : NO; +} + +- (BOOL)failed +{ + return BeeRequest.STATE_FAILED == _state ? YES : NO; +} + +- (BOOL)cancelled +{ + return BeeRequest.STATE_CANCELLED == _state ? YES : NO; +} + +- (BOOL)hasResponder:(id)responder +{ + return [_responders containsObject:responder]; +} + +- (void)addResponder:(id)responder +{ + [_responders addObject:responder]; +} + +- (void)removeResponder:(id)responder +{ + [_responders removeObject:responder]; +} + +- (void)removeAllResponders +{ + [_responders removeAllObjects]; +} + +- (BeeRequestBlockN)HEADER +{ + BeeRequestBlockN block = ^ BeeRequest * ( id first, ... ) + { + va_list args; + va_start( args, first ); + + NSString * key = [(NSObject *)first asNSString]; + NSString * value = [va_arg( args, NSObject * ) asNSString]; + + [self addRequestHeader:key value:(NSString *)value]; + + va_end( args ); + + return self; + }; + + return [[block copy] autorelease]; +} + +- (BeeRequestBlockN)BODY +{ + BeeRequestBlockN block = ^ BeeRequest * ( id first, ... ) + { + NSData * data = nil; + + if ( [first isKindOfClass:[NSData class]] ) + { + data = (NSData *)first; + } + else if ( [first isKindOfClass:[NSString class]] ) + { + data = [(NSString *)first dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]; + } + else if ( [first isKindOfClass:[NSArray class]] ) + { + NSString * text = [NSString queryStringFromArray:(NSArray *)first]; + if ( text ) + { + data = [text dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]; + } + } + else if ( [first isKindOfClass:[NSDictionary class]] ) + { + NSString * text = [NSString queryStringFromDictionary:(NSDictionary *)first]; + if ( text ) + { + data = [text dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]; + } + } + else + { + data = [[first description] dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]; + } + + if ( data ) + { + self.postBody = [NSMutableData dataWithData:data]; + } + + return self; + }; + + return [[block copy] autorelease]; +} + +- (BeeRequestBlockN)PARAM +{ + BeeRequestBlockN block = ^ BeeRequest * ( id first, ... ) + { + va_list args; + va_start( args, first ); + + NSString * key = [(NSString *)first asNSString]; + NSString * value = [va_arg( args, NSObject * ) asNSString]; + + if ( [self.requestMethod is:@"GET"] ) + { + NSString * base = [self.url absoluteString]; + NSString * params = [NSString queryStringFromKeyValues:key, value, nil]; + NSString * query = self.url.query; + + NSURL * newURL = nil; + + if ( query.length ) + { + newURL = [NSURL URLWithString:[base stringByAppendingFormat:@"&%@", params]]; + } + else + { + newURL = [NSURL URLWithString:[base stringByAppendingFormat:@"?%@", params]]; + } + + if ( newURL ) + { + [self setURL:newURL]; + } + } + else + { + [self setPostValue:value forKey:key]; + } + + va_end( args ); + + return self; + }; + + return [[block copy] autorelease]; +} + +- (BeeRequestBlockN)FILE +{ + BeeRequestBlockN block = ^ BeeRequest * ( id first, ... ) + { + va_list args; + va_start( args, first ); + + NSString * name = [(NSString *)first asNSString]; + NSObject * data = va_arg( args, NSObject * ); + + if ( data ) + { + NSString * path; + + path = NSHomeDirectory(); + path = [path stringByAppendingPathComponent:@"Documents"]; + path = [path stringByAppendingPathComponent:name]; + + if ( [data isKindOfClass:[NSString class]] ) + { + NSString * string = (NSString *)data; + [string writeToFile:path + atomically:YES + encoding:NSUTF8StringEncoding + error:NULL]; + } + else if ( [data isKindOfClass:[NSData class]] ) + { + NSData * data = (NSData *)data; + [data writeToFile:path + options:NSDataWritingAtomic + error:NULL]; + } + else + { + NSData * data = [[first description] dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]; + [data writeToFile:path + options:NSDataWritingAtomic + error:NULL]; + } + + [self setFile:path forKey:name]; + } + + va_end( args ); + + return self; + }; + + return [[block copy] autorelease]; +} + +@end diff --git a/BeeFramework/Core/Network/Bee_RequestQueue.h b/BeeFramework/Core/Network/Bee_RequestQueue.h new file mode 100644 index 0000000..a5d7782 --- /dev/null +++ b/BeeFramework/Core/Network/Bee_RequestQueue.h @@ -0,0 +1,98 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_Network.h +// + +#import "Bee_Precompile.h" +#import "Bee_Singleton.h" +#import "Bee_Request.h" + +#pragma mark - + +@interface BeeRequestQueue : NSObject +{ + BOOL _merge; + BOOL _online; + + BOOL _blackListEnable; + NSTimeInterval _blackListTimeout; + NSMutableDictionary * _blackList; + + NSUInteger _bytesUpload; + NSUInteger _bytesDownload; + + NSTimeInterval _delay; + NSMutableArray * _requests; + + BeeRequestBlock _whenCreate; + BeeRequestBlock _whenUpdate; +} + +@property (nonatomic, assign) BOOL merge; +@property (nonatomic, assign) BOOL online; // 开网/断网 + +@property (nonatomic, assign) BOOL blackListEnable; // 是否使用黑名单 +@property (nonatomic, assign) NSTimeInterval blackListTimeout; // 黑名单超时 +@property (nonatomic, retain) NSMutableDictionary * blackList; + +@property (nonatomic, assign) NSUInteger bytesUpload; +@property (nonatomic, assign) NSUInteger bytesDownload; + +@property (nonatomic, assign) NSTimeInterval delay; +@property (nonatomic, retain) NSMutableArray * requests; + +@property (nonatomic, copy) BeeRequestBlock whenCreate; +@property (nonatomic, copy) BeeRequestBlock whenUpdate; + ++ (BeeRequestQueue *)sharedInstance; + ++ (BOOL)isReachableViaWIFI; ++ (BOOL)isReachableViaWLAN; ++ (BOOL)isNetworkInUse; ++ (NSUInteger)bandwidthUsedPerSecond; + ++ (BeeRequest *)GET:(NSString *)url; ++ (BeeRequest *)POST:(NSString *)url; + ++ (BOOL)requesting:(NSString *)url; ++ (BOOL)requesting:(NSString *)url byResponder:(id)responder; + ++ (NSArray *)requests:(NSString *)url; ++ (NSArray *)requests:(NSString *)url byResponder:(id)responder; + ++ (void)cancelRequest:(BeeRequest *)request; ++ (void)cancelRequestByResponder:(id)responder; ++ (void)cancelAllRequests; + ++ (void)blockURL:(NSString *)url; ++ (void)unblockURL:(NSString *)url; + +@end + diff --git a/BeeFramework/Core/Network/Bee_RequestQueue.m b/BeeFramework/Core/Network/Bee_RequestQueue.m new file mode 100644 index 0000000..705803e --- /dev/null +++ b/BeeFramework/Core/Network/Bee_RequestQueue.m @@ -0,0 +1,679 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_Network.m +// + +#include + +#import "Bee_Precompile.h" +#import "Bee_Log.h" +#import "Bee_RequestQueue.h" + +#pragma mark - + +#undef DEFAULT_BLACKLIST_TIMEOUT +#define DEFAULT_BLACKLIST_TIMEOUT (60.0f * 5.0f) // 黑名单超时5分钟 + +#undef DEFAULT_GET_TIMEOUT +#define DEFAULT_GET_TIMEOUT (30.0f) // 取图30秒超时 + +#undef DEFAULT_POST_TIMEOUT +#define DEFAULT_POST_TIMEOUT (30.0f) // 发协议30秒超时 + +#undef DEFAULT_UPLOAD_TIMEOUT +#define DEFAULT_UPLOAD_TIMEOUT (120.0f) // 上传图片120秒超时 + +#pragma mark - + +@interface BeeRequestQueue(Private) + +- (BOOL)checkResourceBroken:(NSString *)url; + +- (BeeRequest *)GET:(NSString *)url sync:(BOOL)sync; +- (BeeRequest *)POST:(NSString *)url sync:(BOOL)sync; + +- (void)cancelRequest:(BeeRequest *)request; +- (void)cancelRequestByResponder:(id)responder; +- (void)cancelAllRequests; + +- (void)blockURL:(NSString *)url; +- (void)unblockURL:(NSString *)url; + +- (BOOL)requesting:(NSString *)url; +- (BOOL)requesting:(NSString *)url byResponder:(id)responder; + +- (NSArray *)requests:(NSString *)url; +- (NSArray *)requests:(NSString *)url byResponder:(id)responder; + +@end + +#pragma mark - + +@implementation BeeRequestQueue + +@synthesize merge = _merge; +@synthesize online = _online; + +@synthesize blackListEnable = _blackListEnable; +@synthesize blackListTimeout = _blackListTimeout; +@synthesize blackList = _blackList; + +@synthesize bytesUpload = _bytesUpload; +@synthesize bytesDownload = _bytesDownload; + +@synthesize delay = _delay; +@synthesize requests = _requests; + +@synthesize whenCreate = _whenCreate; +@synthesize whenUpdate = _whenUpdate; + ++ (BOOL)isReachableViaWIFI +{ + return YES; +} + ++ (BOOL)isReachableViaWLAN +{ + return YES; +} + ++ (BOOL)isNetworkInUse +{ + return ([[BeeRequestQueue sharedInstance].requests count] > 0) ? YES : NO; +} + ++ (NSUInteger)bandwidthUsedPerSecond +{ + return [ASIHTTPRequest averageBandwidthUsedPerSecond]; +} + ++ (BeeRequestQueue *)sharedInstance +{ + static BeeRequestQueue * __sharedInstance = nil; + + @synchronized(self) + { + if ( nil == __sharedInstance ) + { + __sharedInstance = [[BeeRequestQueue alloc] init]; + +// [ASIHTTPRequest setShouldThrottleBandwidthForWWAN:YES]; +// [ASIHTTPRequest throttleBandwidthForWWANUsingLimit:32 * 1024]; // 32K + [ASIHTTPRequest setDefaultUserAgentString:@"Bee"]; + [[ASIHTTPRequest sharedQueue] setMaxConcurrentOperationCount:10]; + } + } + + return (BeeRequestQueue *)__sharedInstance; +} + +- (id)init +{ + self = [super init]; + if ( self ) + { + _delay = 0.1f; + _merge = YES; + _online = YES; + _requests = [[NSMutableArray alloc] init]; + + _blackListEnable = YES; + _blackListTimeout = DEFAULT_BLACKLIST_TIMEOUT; + _blackList = [[NSMutableDictionary alloc] init]; + } + + return self; +} + +- (void)setOnline:(BOOL)en +{ + _online = en; + + if ( NO == _online ) + { + [self cancelAllRequests]; + } +} + +- (void)dealloc +{ + [self cancelAllRequests]; + + [_requests removeAllObjects]; + [_requests release]; + + [_blackList removeAllObjects]; + [_blackList release]; + + self.whenCreate = nil; + self.whenUpdate = nil; + + [super dealloc]; +} + +- (BOOL)checkResourceBroken:(NSString *)url +{ + if ( _blackListEnable ) + { + NSDate * date = nil; + NSDate * now = [NSDate date]; + + date = [_blackList objectForKey:url]; + if ( date && ([date timeIntervalSince1970] - [now timeIntervalSince1970]) < _blackListTimeout ) + { + #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ + CC( @"resource broken: %@", url ); + #endif // #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ + + return YES; + } + } + + return NO; +} + ++ (BeeRequest *)GET:(NSString *)url +{ + return [[BeeRequestQueue sharedInstance] GET:url sync:NO]; +} + +- (BeeRequest *)GET:(NSString *)url sync:(BOOL)sync +{ + if ( NO == _online ) + return nil; + + if ( [self checkResourceBroken:url] ) + { + return nil; + } + + BeeRequest * request = nil; + + if ( NO == sync && _merge ) + { + for ( BeeRequest * req in _requests ) + { + if ( [req.url.absoluteString isEqualToString:url] ) + { + return req; + } + } + } + +#if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ + CC( @"GET %@\n", url ); +#endif // #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ + + request = [[BeeRequest alloc] initWithURL:[NSURL URLWithString:url]]; + request.timeOutSeconds = DEFAULT_GET_TIMEOUT; + request.requestMethod = @"GET"; + request.postBody = nil; + [request setDelegate:self]; + [request setDownloadProgressDelegate:self]; + [request setUploadProgressDelegate:self]; + + [request setNumberOfTimesToRetryOnTimeout:2]; +#if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 + [request setShouldContinueWhenAppEntersBackground:YES]; +#endif // #if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 + + [request setThreadPriority:0.5]; + [request setQueuePriority:NSOperationQueuePriorityLow]; + + [_requests addObject:request]; + + if ( self.whenCreate ) + { + self.whenCreate( request ); + } + + if ( sync ) + { + [request startSynchronous]; + } + else + { + if ( _delay ) + { + [request performSelector:@selector(startAsynchronous) + withObject:nil + afterDelay:_delay]; + } + else + { + [request startAsynchronous]; + } + } + + return [request autorelease]; +} + ++ (BeeRequest *)POST:(NSString *)url +{ + return [[BeeRequestQueue sharedInstance] POST:url sync:NO]; +} + +- (BeeRequest *)POST:(NSString *)url sync:(BOOL)sync +{ + if ( NO == _online ) + return nil; + + BeeRequest * request = nil; + +#if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ + CC( @"POST %@\n", url ); +#endif // #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ + + request = [[BeeRequest alloc] initWithURL:[NSURL URLWithString:url]]; + request.timeOutSeconds = DEFAULT_POST_TIMEOUT; + request.requestMethod = @"POST"; + request.postFormat = ASIMultipartFormDataPostFormat; // ASIRawPostFormat; + [request setDelegate:self]; + [request setDownloadProgressDelegate:self]; + [request setUploadProgressDelegate:self]; + [request setNumberOfTimesToRetryOnTimeout:2]; +#if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 + [request setShouldContinueWhenAppEntersBackground:YES]; +#endif // #if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 + + [request setThreadPriority:1.0]; + [request setQueuePriority:NSOperationQueuePriorityHigh]; + + [_requests addObject:request]; + + if ( self.whenCreate ) + { + self.whenCreate( request ); + } + + if ( sync ) + { + [request startSynchronous]; + } + else + { + if ( _delay ) + { + [request performSelector:@selector(startAsynchronous) + withObject:nil + afterDelay:_delay]; + } + else + { + [request startAsynchronous]; + } + } + + return [request autorelease]; +} + ++ (BOOL)requesting:(NSString *)url +{ + return [[BeeRequestQueue sharedInstance] requesting:url]; +} + +- (BOOL)requesting:(NSString *)url +{ + for ( BeeRequest * request in _requests ) + { + if ( [[request.url absoluteString] isEqualToString:url] ) + { + return YES; + } + } + + return NO; +} + ++ (BOOL)requesting:(NSString *)url byResponder:(id)responder +{ + return [[BeeRequestQueue sharedInstance] requesting:url byResponder:responder]; +} + +- (BOOL)requesting:(NSString *)url byResponder:(id)responder +{ + for ( BeeRequest * request in _requests ) + { + if ( responder && NO == [request hasResponder:responder] /*request.responder != responder*/ ) + continue; + + if ( nil == url || [[request.url absoluteString] isEqualToString:url] ) + { + return YES; + } + } + + return NO; +} + ++ (NSArray *)requests:(NSString *)url +{ + return [[BeeRequestQueue sharedInstance] requests:url]; +} + +- (NSArray *)requests:(NSString *)url +{ + NSMutableArray * array = [NSMutableArray array]; + + for ( BeeRequest * request in _requests ) + { + if ( [[request.url absoluteString] isEqualToString:url] ) + { + [array addObject:request]; + } + } + + return array; +} + ++ (NSArray *)requests:(NSString *)url byResponder:(id)responder +{ + return [[BeeRequestQueue sharedInstance] requests:url byResponder:responder]; +} + +- (NSArray *)requests:(NSString *)url byResponder:(id)responder +{ + NSMutableArray * array = [NSMutableArray array]; + + for ( BeeRequest * request in _requests ) + { + if ( responder && NO == [request hasResponder:responder] /* request.responder != responder */ ) + continue; + + if ( nil == url || [[request.url absoluteString] isEqualToString:url] ) + { + [array addObject:request]; + } + } + + return array; +} + ++ (void)cancelRequest:(BeeRequest *)request +{ + [[BeeRequestQueue sharedInstance] cancelRequest:request]; +} + +- (void)cancelRequest:(BeeRequest *)request +{ + [NSObject cancelPreviousPerformRequestsWithTarget:request selector:@selector(startAsynchronous) object:nil]; + + if ( [_requests containsObject:request] ) + { + if ( request.created || request.sending || request.recving ) + { + [request changeState:BeeRequest.STATE_CANCELLED]; + } + + [request clearDelegatesAndCancel]; + [request removeAllResponders]; + + [_requests removeObject:request]; + } +} + ++ (void)cancelRequestByResponder:(id)responder +{ + [[BeeRequestQueue sharedInstance] cancelRequestByResponder:responder]; +} + +- (void)cancelRequestByResponder:(id)responder +{ + if ( nil == responder ) + { + [self cancelAllRequests]; + } + else + { + NSMutableArray * tempArray = [NSMutableArray array]; + + for ( BeeRequest * request in _requests ) + { + if ( [request hasResponder:responder] /* request.responder == responder */ ) + { + [tempArray addObject:request]; + } + } + + for ( BeeRequest * request in tempArray ) + { + [self cancelRequest:request]; + } + } +} + ++ (void)cancelAllRequests +{ + [[BeeRequestQueue sharedInstance] cancelAllRequests]; +} + +- (void)cancelAllRequests +{ + for ( BeeRequest * request in _requests ) + { + [self cancelRequest:request]; + } +} + ++ (void)blockURL:(NSString *)url +{ + [[BeeRequestQueue sharedInstance] blockURL:url]; +} + +- (void)blockURL:(NSString *)url +{ + [_blackList setObject:[NSDate date] forKey:url]; +} + ++ (void)unblockURL:(NSString *)url +{ + [[BeeRequestQueue sharedInstance] unblockURL:url]; +} + +- (void)unblockURL:(NSString *)url +{ + if ( [_blackList objectForKey:url] ) + { + NSDate * date = [NSDate dateWithTimeInterval:(_blackListTimeout + 1.0f) sinceDate:[NSDate date]]; + [_blackList setObject:date forKey:url]; + } +} + +- (NSArray *)requests +{ + return _requests; +} + +#pragma mark - +#pragma mark ASIHTTPRequestDelegate + +- (void)requestStarted:(ASIHTTPRequest *)request +{ + if ( NO == [request isKindOfClass:[BeeRequest class]] ) + return; + + BeeRequest * networkRequest = (BeeRequest *)request; + [networkRequest changeState:BeeRequest.STATE_SENDING]; + + _bytesUpload += request.postLength; + + if ( self.whenUpdate ) + { + self.whenUpdate( networkRequest ); + } +} + +- (void)request:(ASIHTTPRequest *)request didReceiveResponseHeaders:(NSDictionary *)responseHeaders +{ + if ( NO == [request isKindOfClass:[BeeRequest class]] ) + return; + + BeeRequest * networkRequest = (BeeRequest *)request; + [networkRequest changeState:BeeRequest.STATE_RECVING]; + + if ( self.whenUpdate ) + { + self.whenUpdate( networkRequest ); + } +} + +- (void)requestFinished:(ASIHTTPRequest *)request +{ + _bytesDownload += [[request rawResponseData] length]; + + if ( NO == [request isKindOfClass:[BeeRequest class]] ) + return; + + BeeRequest * networkRequest = (BeeRequest *)request; + +#if __BEE_DEVELOPMENT__ + CC( @"\nHTTP %d(%@)\n%@\n", + request.responseStatusCode, + request.responseStatusMessage, + [request.url absoluteString] ); +#endif + + if ( [request.requestMethod isEqualToString:@"GET"] ) + { + if ( request.responseStatusCode >= 400 && request.responseStatusCode < 500 ) + { + [self blockURL:[request.url absoluteString]]; + } + } + + if ( 200 == request.responseStatusCode ) + { + [networkRequest changeState:BeeRequest.STATE_SUCCEED]; + } + else + { + [networkRequest changeState:BeeRequest.STATE_FAILED]; + } + + [networkRequest clearDelegatesAndCancel]; + [networkRequest removeAllResponders]; + + [_requests removeObject:networkRequest]; + + if ( self.whenUpdate ) + { + self.whenUpdate( networkRequest ); + } +} + +- (void)requestFailed:(ASIHTTPRequest *)request +{ + if ( NO == [request isKindOfClass:[BeeRequest class]] ) + return; + + BeeRequest * networkRequest = (BeeRequest *)request; + + networkRequest.errorCode = -1; + [networkRequest changeState:BeeRequest.STATE_FAILED]; + + [networkRequest clearDelegatesAndCancel]; + [networkRequest removeAllResponders]; + + [_requests removeObject:networkRequest]; + + if ( self.whenUpdate ) + { + self.whenUpdate( networkRequest ); + } +} + +#pragma mark - + +- (void)request:(ASIHTTPRequest *)request willRedirectToURL:(NSURL *)newURL +{ + [self requestFailed:request]; +} + +- (void)requestRedirected:(ASIHTTPRequest *)request +{ + [self requestFailed:request]; +} + +- (void)authenticationNeededForRequest:(ASIHTTPRequest *)request +{ + [self requestFailed:request]; +} + +- (void)proxyAuthenticationNeededForRequest:(ASIHTTPRequest *)request +{ + [self requestFailed:request]; +} + +#pragma mark - + +// Called when the request receives some data - bytes is the length of that data +- (void)request:(ASIHTTPRequest *)request didReceiveBytes:(long long)bytes +{ + if ( NO == [request isKindOfClass:[BeeRequest class]] ) + return; + + BeeRequest * networkRequest = (BeeRequest *)request; + [networkRequest updateRecvProgress]; +} + +// Called when the request sends some data +// The first 32KB (128KB on older platforms) of data sent is not included in this amount because of limitations with the CFNetwork API +// bytes may be less than zero if a request needs to remove upload progress (probably because the request needs to run again) +- (void)request:(ASIHTTPRequest *)request didSendBytes:(long long)bytes +{ + if ( NO == [request isKindOfClass:[BeeRequest class]] ) + return; + + BeeRequest * networkRequest = (BeeRequest *)request; + [networkRequest updateSendProgress]; +} + +// Called when a request needs to change the length of the content to download +- (void)request:(ASIHTTPRequest *)request incrementDownloadSizeBy:(long long)newLength +{ + if ( NO == [request isKindOfClass:[BeeRequest class]] ) + return; + + BeeRequest * networkRequest = (BeeRequest *)request; + [networkRequest updateRecvProgress]; +} + +// Called when a request needs to change the length of the content to upload +// newLength may be less than zero when a request needs to remove the size of the internal buffer from progress tracking +- (void)request:(ASIHTTPRequest *)request incrementUploadSizeBy:(long long)newLength +{ + if ( NO == [request isKindOfClass:[BeeRequest class]] ) + return; + + BeeRequest * networkRequest = (BeeRequest *)request; + [networkRequest updateSendProgress]; +} + +@end diff --git a/BeeFramework/Core/Network/Extension/NSObject+BeeRequest.h b/BeeFramework/Core/Network/Extension/NSObject+BeeRequest.h new file mode 100644 index 0000000..1babac2 --- /dev/null +++ b/BeeFramework/Core/Network/Extension/NSObject+BeeRequest.h @@ -0,0 +1,59 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// NSObject+BeeRequest.h +// + +#import "Bee_Precompile.h" +#import "Bee_Request.h" +#import "Bee_RequestQueue.h" + +#pragma mark - + +@interface NSObject(BeeRequestResponder) + +@property (nonatomic, readonly) BeeRequestBlockS HTTP_GET; +@property (nonatomic, readonly) BeeRequestBlockS HTTP_POST; + +- (BeeRequest *)GET:(NSString *)url; +- (BeeRequest *)POST:(NSString *)url; + +- (BeeRequest *)HTTP_GET:(NSString *)url; +- (BeeRequest *)HTTP_POST:(NSString *)url; + +- (BOOL)isRequestResponder; +- (BOOL)requestingURL; +- (BOOL)requestingURL:(NSString *)url; +- (NSArray *)requests; +- (NSArray *)requests:(NSString *)url; +- (void)cancelRequests; + +- (void)handleRequest:(BeeRequest *)request; + +@end diff --git a/BeeFramework/Core/Network/Extension/NSObject+BeeRequest.m b/BeeFramework/Core/Network/Extension/NSObject+BeeRequest.m new file mode 100644 index 0000000..51049b5 --- /dev/null +++ b/BeeFramework/Core/Network/Extension/NSObject+BeeRequest.m @@ -0,0 +1,150 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// NSObject+BeeRequest.m +// + +#include + +#import "Bee_Precompile.h" +#import "NSObject+BeeRequest.h" + +#pragma mark - + +@implementation NSObject(BeeRequestResponder) + +@dynamic HTTP_GET; +@dynamic HTTP_POST; + +- (BeeRequest *)GET:(NSString *)url +{ + return [self HTTP_GET:url]; +} + +- (BeeRequest *)POST:(NSString *)url +{ + return [self HTTP_POST:url]; +} + +- (BeeRequest *)HTTP_GET:(NSString *)url +{ + BeeRequest * req = [BeeRequestQueue GET:url]; + [req addResponder:self]; + return req; +} + +- (BeeRequest *)HTTP_POST:(NSString *)url +{ + BeeRequest * req = [BeeRequestQueue POST:url]; + [req addResponder:self]; + return req; +} + +- (BOOL)isRequestResponder +{ + if ( [self respondsToSelector:@selector(handleRequest:)] ) + { + return YES; + } + + return NO; +} + +- (BeeRequestBlockS)HTTP_GET +{ + BeeRequestBlockS block = ^ BeeRequest * ( NSString * url ) + { + BeeRequest * req = [BeeRequestQueue GET:url]; + [req addResponder:self]; + return req; + }; + + return [[block copy] autorelease]; +} + +- (BeeRequestBlockS)HTTP_POST +{ + BeeRequestBlockS block = ^ BeeRequest * ( NSString * url ) + { + BeeRequest * req = [BeeRequestQueue POST:url]; + [req addResponder:self]; + return req; + }; + + return [[block copy] autorelease]; +} + +- (BOOL)requestingURL +{ + if ( [self isRequestResponder] ) + { + return [BeeRequestQueue requesting:nil byResponder:self]; + } + else + { + return NO; + } +} + +- (BOOL)requestingURL:(NSString *)url +{ + if ( [self isRequestResponder] ) + { + return [BeeRequestQueue requesting:url byResponder:self]; + } + else + { + return NO; + } +} + +- (NSArray *)requests +{ + return [BeeRequestQueue requests:nil byResponder:self]; +} + +- (NSArray *)requests:(NSString *)url +{ + return [BeeRequestQueue requests:url byResponder:self]; +} + +- (void)cancelRequests +{ + if ( [self isRequestResponder] ) + { + [BeeRequestQueue cancelRequestByResponder:self]; + } +} + +- (void)handleRequest:(BeeRequest *)request +{ +} + +@end + diff --git a/BeeFramework/Core/Storage/Bee_ActiveBase.h b/BeeFramework/Core/Storage/Bee_ActiveBase.h new file mode 100644 index 0000000..96d867d --- /dev/null +++ b/BeeFramework/Core/Storage/Bee_ActiveBase.h @@ -0,0 +1,124 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_ActiveBase.h +// + +#import "Bee_Precompile.h" +#import "Bee_Database.h" + +#include + +#pragma mark - + +@interface NSObject(BeeActiveBase) + ++ (void)mapRelation; // for subclass + ++ (void)mapPropertyAsKey:(NSString *)name; ++ (void)mapPropertyAsKey:(NSString *)name defaultValue:(id)value; ++ (void)mapPropertyAsKey:(NSString *)name atPath:(NSString *)path; ++ (void)mapPropertyAsKey:(NSString *)name atPath:(NSString *)path defaultValue:(id)value; + ++ (void)mapProperty:(NSString *)name; ++ (void)mapProperty:(NSString *)name defaultValue:(id)value; ++ (void)mapProperty:(NSString *)name atPath:(NSString *)path; ++ (void)mapProperty:(NSString *)name atPath:(NSString *)path defaultValue:(id)value; ++ (void)mapProperty:(NSString *)name forClass:(NSString *)className; ++ (void)mapProperty:(NSString *)name forClass:(NSString *)className defaultValue:(id)value; ++ (void)mapProperty:(NSString *)name forClass:(NSString *)className atPath:(NSString *)path; ++ (void)mapProperty:(NSString *)name forClass:(NSString *)className atPath:(NSString *)path defaultValue:(id)value; ++ (void)mapProperty:(NSString *)name associateTo:(NSString *)clazz; ++ (void)mapProperty:(NSString *)name associateTo:(NSString *)clazz defaultValue:(id)value; + ++ (void)useAutoIncrement; ++ (void)useAutoIncrementFor:(Class)clazz; ++ (BOOL)usingAutoIncrement; ++ (BOOL)usingAutoIncrementFor:(Class)clazz; + ++ (void)useJSON; ++ (void)useJSONFor:(Class)clazz; ++ (BOOL)usingJSON; ++ (BOOL)usingJSONFor:(Class)clazz; + +- (NSString *)activePrimaryKey; ++ (NSString *)activePrimaryKey; ++ (NSString *)activePrimaryKeyFor:(Class)clazz; + +- (NSString *)activeJSONKey; ++ (NSString *)activeJSONKey; ++ (NSString *)activeJSONKeyFor:(Class)clazz; + +- (NSMutableDictionary *)activePropertySet; ++ (NSMutableDictionary *)activePropertySet; ++ (NSMutableDictionary *)activePropertySetFor:(Class)clazz; + ++ (void)prepareOnceWithRootClass:(Class)clazz; ++ (void)resetPrepareFlags; + +@end + +#pragma mark - + +@protocol BeeActiveProtocol + +@property (nonatomic, readonly) BeeDatabaseBoolBlock EXISTS; // COUNT WHERE '' = id +@property (nonatomic, readonly) BeeDatabaseBoolBlock LOAD; // GET +@property (nonatomic, readonly) BeeDatabaseBoolBlock SAVE; // INSERT if failed to UPDATE +@property (nonatomic, readonly) BeeDatabaseBoolBlock INSERT; +@property (nonatomic, readonly) BeeDatabaseBoolBlock UPDATE; +@property (nonatomic, readonly) BeeDatabaseBoolBlock DELETE; + +@property (nonatomic, readonly) NSString * primaryKey; +@property (nonatomic, retain) NSNumber * primaryID; + +@property (nonatomic, readonly) BOOL changed; +@property (nonatomic, readonly) BOOL deleted; + +@property (nonatomic, retain) NSMutableDictionary * JSON; +@property (nonatomic, retain) NSData * JSONData; +@property (nonatomic, retain) NSString * JSONString; + +- (id)initWithObject:(NSObject *)object; +- (id)initWithDictionary:(NSDictionary *)dict; +- (id)initWithJSONData:(NSData *)data; +- (id)initWithJSONString:(NSString *)string; + +- (void)setDictionary:(NSDictionary *)dict; + +- (void)load; // for subclass +- (void)unload; // for subclass + +@end + +#pragma mark - + +@interface NonValue : NSObject ++ (NonValue *)value; +@end diff --git a/BeeFramework/Core/Storage/Bee_ActiveBase.m b/BeeFramework/Core/Storage/Bee_ActiveBase.m new file mode 100644 index 0000000..86a19ae --- /dev/null +++ b/BeeFramework/Core/Storage/Bee_ActiveBase.m @@ -0,0 +1,565 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_ActiveBase.h +// + +#import "Bee_Precompile.h" +#import "Bee_Log.h" +#import "Bee_Runtime.h" +#import "Bee_Database.h" +#import "Bee_ActiveBase.h" + +#import "NSObject+BeeTypeConversion.h" +#import "NSDictionary+BeeExtension.h" +#import "NSNumber+BeeExtension.h" +#import "NSObject+BeeDatabase.h" + +#include + +#pragma mark - + +@interface NSObject(BeeActiveBasePrivate) ++ (NSString *)keyPath:(NSString *)path; ++ (void)addProtperty:(NSString *)name + atPath:(NSString *)path + forClass:(NSString *)className + associateTo:(NSString *)domain + defaultValue:(id)value + key:(BOOL)key; +@end + +@implementation NSObject(BeeActiveBase) + +static NSMutableDictionary * __primaryKeys = nil; +static NSMutableDictionary * __properties = nil; +static NSMutableDictionary * __usingAI = nil; +static NSMutableDictionary * __usingJSON = nil; +static NSMutableDictionary * __flags = nil; + ++ (void)mapRelation +{ +} + ++ (void)mapPropertyAsKey:(NSString *)name +{ + [self addProtperty:name + atPath:nil + forClass:nil + associateTo:nil + defaultValue:nil + key:YES]; +} + ++ (void)mapPropertyAsKey:(NSString *)name defaultValue:(id)value +{ + [self addProtperty:name + atPath:nil + forClass:nil + associateTo:nil + defaultValue:value + key:YES]; +} + ++ (void)mapPropertyAsKey:(NSString *)name atPath:(NSString *)path +{ + [self addProtperty:name + atPath:path + forClass:nil + associateTo:nil + defaultValue:nil + key:YES]; +} + ++ (void)mapPropertyAsKey:(NSString *)name atPath:(NSString *)path defaultValue:(id)value +{ + [self addProtperty:name + atPath:path + forClass:nil + associateTo:nil + defaultValue:value + key:YES]; +} + ++ (void)mapProperty:(NSString *)name +{ + [self addProtperty:name + atPath:nil + forClass:nil + associateTo:nil + defaultValue:nil + key:NO]; +} + ++ (void)mapProperty:(NSString *)name defaultValue:(id)value +{ + [self addProtperty:name + atPath:nil + forClass:nil + associateTo:nil + defaultValue:value + key:NO]; +} + ++ (void)mapProperty:(NSString *)name atPath:(NSString *)path +{ + [self addProtperty:name + atPath:path + forClass:nil + associateTo:nil + defaultValue:nil + key:NO]; +} + ++ (void)mapProperty:(NSString *)name atPath:(NSString *)path defaultValue:(id)value +{ + [self addProtperty:name + atPath:path + forClass:nil + associateTo:nil + defaultValue:value + key:NO]; +} + ++ (void)mapProperty:(NSString *)name forClass:(NSString *)className +{ + [self addProtperty:name + atPath:nil + forClass:className + associateTo:nil + defaultValue:nil + key:NO]; +} + ++ (void)mapProperty:(NSString *)name forClass:(NSString *)className defaultValue:(id)value +{ + [self addProtperty:name + atPath:nil + forClass:className + associateTo:nil + defaultValue:value + key:NO]; +} + ++ (void)mapProperty:(NSString *)name forClass:(NSString *)className atPath:(NSString *)path +{ + [self addProtperty:name + atPath:path + forClass:className + associateTo:nil + defaultValue:nil + key:NO]; +} + ++ (void)mapProperty:(NSString *)name forClass:(NSString *)className atPath:(NSString *)path defaultValue:(id)value +{ + [self addProtperty:name + atPath:path + forClass:className + associateTo:nil + defaultValue:value + key:NO]; +} + ++ (void)mapProperty:(NSString *)name associateTo:(NSString *)domain +{ + [self addProtperty:name + atPath:nil + forClass:nil + associateTo:domain + defaultValue:nil + key:NO]; +} + ++ (void)mapProperty:(NSString *)name associateTo:(NSString *)domain defaultValue:(id)value +{ + [self addProtperty:name + atPath:nil + forClass:nil + associateTo:domain + defaultValue:value + key:NO]; +} + ++ (void)addProtperty:(NSString *)name + atPath:(NSString *)path + forClass:(NSString *)className + associateTo:(NSString *)domain + defaultValue:(id)value + key:(BOOL)key +{ + // add primary key + + if ( key ) + { + if ( nil == __primaryKeys ) + { + __primaryKeys = [[NSMutableDictionary alloc] init]; + } + + [__primaryKeys setObject:name forKey:[self description]]; + } + + // add property + + if ( nil == __properties ) + { + __properties = [[NSMutableDictionary alloc] init]; + } + + NSMutableDictionary * propertySet = self.activePropertySet; + if ( propertySet ) + { + NSMutableDictionary * property = [propertySet objectForKey:name]; + if ( nil == property ) + { + property = [NSMutableDictionary dictionary]; + [propertySet setObject:property forKey:name]; + } + + if ( property ) + { + [property setObject:name forKey:@"name"]; + [property setObject:(key ? @"YES" : @"NO") forKey:@"key"]; + [property setObject:[BeeDatabase fieldNameForIdentifier:name] forKey:@"field"]; + + if ( domain ) + { + NSArray * components = [domain componentsSeparatedByString:@"."]; + if ( components.count >= 2 ) + { + NSString * className = [components objectAtIndex:0]; + NSString * propertyName = [components objectAtIndex:1]; + + [property setObject:className forKey:@"associateClass"]; + [property setObject:propertyName forKey:@"associateProperty"]; + } + else + { + [property setObject:domain forKey:@"associateClass"]; + } + } + + if ( className ) + { + [property setObject:className forKey:@"className"]; + } + + path = path ? [self keyPath:path] : name; + if ( path ) + { + [property setObject:path forKey:@"path"]; + } + + if ( value ) + { + [property setObject:value forKey:@"value"]; + } + else + { + [property setObject:[NonValue value] forKey:@"value"]; + } + } + } +} + ++ (void)useAutoIncrement +{ + [self useAutoIncrementFor:self]; +} + ++ (void)useAutoIncrementFor:(Class)clazz +{ + if ( nil == __usingAI ) + { + __usingAI = [[NSMutableDictionary alloc] init]; + } + + [__usingAI setObject:__INT(YES) forKey:[clazz description]]; +} + ++ (BOOL)usingAutoIncrement +{ + return [self usingAutoIncrementFor:self]; +} + ++ (BOOL)usingAutoIncrementFor:(Class)clazz +{ + if ( nil == __usingAI ) + return NO; + + NSNumber * flag = [__usingAI objectForKey:[clazz description]]; + return flag ? flag.boolValue : NO; +} + ++ (void)useJSON +{ + [self useJSONFor:self]; +} + ++ (void)useJSONFor:(Class)clazz +{ + if ( nil == __usingJSON ) + { + __usingJSON = [[NSMutableDictionary alloc] init]; + } + + [__usingJSON setObject:__INT(YES) forKey:[clazz description]]; +} + ++ (BOOL)usingJSON +{ + return [self usingJSONFor:self]; +} + ++ (BOOL)usingJSONFor:(Class)clazz +{ + if ( nil == __usingJSON ) + return NO; + + NSNumber * flag = [__usingJSON objectForKey:[clazz description]]; + return flag ? flag.boolValue : NO; +} + ++ (NSString *)keyPath:(NSString *)path +{ + NSString * keyPath = [path stringByReplacingOccurrencesOfString:@"/" withString:@"."]; + NSRange range = NSMakeRange( 0, 1 ); + + if ( [[keyPath substringWithRange:range] isEqualToString:@"."] ) + { + keyPath = [keyPath substringFromIndex:1]; + } + + return keyPath; +} + +- (NSString *)activePrimaryKey +{ + return [[self class] activePrimaryKey]; +} + ++ (NSString *)activePrimaryKey +{ + return [self activePrimaryKeyFor:self]; +} + ++ (NSString *)activePrimaryKeyFor:(Class)clazz +{ + if ( __primaryKeys ) + { + NSString * key = [clazz description]; + NSString * value = (NSString *)[__primaryKeys objectForKey:key]; + if ( value ) + return value; + } + + return nil; +} + +- (NSString *)activeJSONKey +{ + return [[self class] activeJSONKey]; +} + ++ (NSString *)activeJSONKey +{ + return [self activeJSONKeyFor:self]; +} + ++ (NSString *)activeJSONKeyFor:(Class)clazz +{ + return nil; +} + +- (NSMutableDictionary *)activePropertySet +{ + return [[self class] activePropertySet]; +} + ++ (NSMutableDictionary *)activePropertySet +{ + return [self activePropertySetFor:self]; +} + ++ (NSMutableDictionary *)activePropertySetFor:(Class)clazz +{ + if ( nil == __properties ) + { + __properties = [[NSMutableDictionary alloc] init]; + } + + NSString * className = [clazz description]; + NSMutableDictionary * propertySet = [__properties objectForKey:className]; + if ( nil == propertySet ) + { + propertySet = [NSMutableDictionary dictionary]; + [__properties setObject:propertySet forKey:className]; + } + + return propertySet; +} + ++ (void)prepareOnceWithRootClass:(Class)rootClass +{ + if ( nil == __flags ) + { + __flags = [[NSMutableDictionary alloc] init]; + } + + NSString * className = [self description]; + NSNumber * flag = [__flags objectForKey:className]; + if ( nil == flag || NO == flag.boolValue ) + { + [self mapRelation]; + + [NSObject DB] + .TABLE( self.tableName ) + .FIELD( self.activePrimaryKey, @"INTEGER" ).PRIMARY_KEY(); + + if ( [self usingAutoIncrement] ) + { + [NSObject DB].AUTO_INREMENT(); + } + + if ( [self usingJSON] ) + { + [NSObject DB] + .TABLE( self.tableName ) + .FIELD( self.activeJSONKey, @"TEXT" ).DEFAULT( @"" ); + } + + NSDictionary * propertySet = self.activePropertySet; + if ( propertySet && propertySet.count ) + { + for ( Class clazzType = [self class];; ) + { + if ( clazzType == rootClass ) + break; + + NSUInteger propertyCount = 0; + objc_property_t * properties = class_copyPropertyList( clazzType, &propertyCount ); + + for ( NSUInteger i = 0; i < propertyCount; i++ ) + { + const char * name = property_getName(properties[i]); + NSString * propertyName = [NSString stringWithCString:name encoding:NSUTF8StringEncoding]; + + NSMutableDictionary * property = [propertySet objectForKey:propertyName]; + if ( property ) + { + const char * attr = property_getAttributes(properties[i]); + NSUInteger type = [BeeTypeEncoding typeOf:attr]; + + NSString * field = [property objectForKey:@"field"]; + NSObject * value = [property objectForKey:@"value"]; + + if ( BeeTypeEncoding.NSNUMBER == type ) + { + [NSObject DB].FIELD( field, @"INTEGER" ); + } + else if ( BeeTypeEncoding.NSSTRING == type ) + { + [NSObject DB].FIELD( field, @"TEXT" ); + } + else if ( BeeTypeEncoding.NSDATE == type ) + { + [NSObject DB].FIELD( field, @"TEXT" ); + } +// else if ( BeeTypeEncoding.NSARRAY == type ) +// { +// [NSObject DB].FIELD( field, @"TEXT" ); +// } +// else if ( BeeTypeEncoding.NSDICTIONARY == type ) +// { +// [NSObject DB].FIELD( field, @"TEXT" ); +// } + else if ( BeeTypeEncoding.OBJECT == type ) + { + // AR对象只存它的主键 + + [NSObject DB].FIELD( field, @"INTEGER" ); + } + else + { + [NSObject DB].FIELD( field, @"INTEGER" ); + } + + if ( value && NO == [value isKindOfClass:[NonValue class]] ) + { + [NSObject DB].DEFAULT( value ); + } + + [property setObject:__INT(type) forKey:@"type"]; + } + } + + free( properties ); + + clazzType = class_getSuperclass( clazzType ); + if ( nil == clazzType ) + break; + } + } + + [NSObject DB] + .CREATE_IF_NOT_EXISTS(); + + [NSObject DB] + .TABLE( self.tableName ) + .INDEX_ON( self.activePrimaryKey, nil ); + + [__flags setObject:__INT(YES) forKey:className]; + } +} + ++ (void)resetPrepareFlags +{ + [__flags removeAllObjects]; +} + +@end + +#pragma mark - + +@implementation NonValue + ++ (NonValue *)value +{ + static NonValue * __value = nil; + + if ( nil == __value ) + { + __value = [[NonValue alloc] init]; + } + + return __value; +} + +@end diff --git a/BeeFramework/Core/Storage/Bee_ActiveBaseTest.m b/BeeFramework/Core/Storage/Bee_ActiveBaseTest.m new file mode 100644 index 0000000..dce781b --- /dev/null +++ b/BeeFramework/Core/Storage/Bee_ActiveBaseTest.m @@ -0,0 +1,44 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_ActiveBaseTest.h +// + +#import "Bee.h" + +#if defined(__BEE_UNITTEST__) && __BEE_UNITTEST__ + +#pragma mark - + +TEST_CASE(BeeActiveBase) +{ +} +TEST_CASE_END + +#endif // #if defined(__BEE_UNITTEST__) && __BEE_UNITTEST__ diff --git a/BeeFramework/Storage/Bee_ActiveRecord.h b/BeeFramework/Core/Storage/Bee_ActiveRecord.h similarity index 54% rename from BeeFramework/Storage/Bee_ActiveRecord.h rename to BeeFramework/Core/Storage/Bee_ActiveRecord.h index d6d0cad..7bd2b1a 100644 --- a/BeeFramework/Storage/Bee_ActiveRecord.h +++ b/BeeFramework/Core/Storage/Bee_ActiveRecord.h @@ -32,63 +32,70 @@ #import "Bee_Precompile.h" #import "Bee_Database.h" +#import "Bee_ActiveBase.h" #include #pragma mark - -@class BeeBaseActiveRecord; -@class BeeActiveRecord; - -#pragma mark - - -@interface BeeBaseActiveRecord : NSObject - -- (id)initWithDict:(NSDictionary *)dict; -- (void)bindDict:(NSDictionary *)dict; - -- (void)load; // for subclass -- (void)unload; // for subclass +@interface BeeActiveRecord : NSObject +{ + BOOL _changed; + BOOL _deleting; + BOOL _deleted; + NSMutableDictionary * _JSON; +} -- (BOOL)insert; -- (BOOL)update; -- (BOOL)delete; ++ (id)record; ++ (id)record:(NSObject *)otherObject; ++ (id)recordWithKey:(NSNumber *)key; ++ (id)recordWithObject:(NSObject *)otherObject; ++ (id)recordWithDictionary:(NSDictionary *)dict; ++ (id)recordWithJSONData:(NSData *)data; ++ (id)recordWithJSONString:(NSString *)string; @end #pragma mark - -typedef BOOL (^BeeActiveRecordBoolBlock)( void ); +@interface NSArray(BeeActiveRecord) +- (NSArray *)activeRecordsFromArray:(Class)clazz; +@end #pragma mark - -@interface BeeActiveRecord : BeeBaseActiveRecord -{ - NSNumber * _ID; -} - -@property (nonatomic, retain) NSNumber * ID; // default primary key - -@property (nonatomic, readonly) BeeActiveRecordBoolBlock INSERT; -@property (nonatomic, readonly) BeeActiveRecordBoolBlock UPDATE; -@property (nonatomic, readonly) BeeActiveRecordBoolBlock DELETE; - -+ (void)mapRelation; // for subclass -+ (void)mapPropertyAsKey:(NSString *)name; -+ (void)mapProperty:(NSString *)name; -+ (void)mapProperty:(NSString *)name defaultValue:(id)value; - -+ (NSString *)tableNameFor:(Class)clazz; - +@interface NSDictionary(BeeActiveRecord) +- (BeeActiveRecord *)activeRecordFromDictionary:(Class)clazz; @end #pragma mark - @interface BeeDatabase(BeeActiveRecord) -@property (nonatomic, readonly) BeeDatabaseBlockN CLASS; +@property (nonatomic, readonly) BeeDatabaseBlockN BELONG_TO; +@property (nonatomic, readonly) BeeDatabaseBlockN HAS; + +@property (nonatomic, readonly) BeeDatabaseBlockN SAVE; +@property (nonatomic, readonly) BeeDatabaseBlockN SAVE_ARRAY; +@property (nonatomic, readonly) BeeDatabaseBlockN SAVE_DICTIONARY; + @property (nonatomic, readonly) BeeDatabaseArrayBlock GET_RECORDS; +@property (nonatomic, readonly) BeeDatabaseObjectBlock FIRST_RECORD; +@property (nonatomic, readonly) BeeDatabaseObjectBlockN FIRST_RECORD_BY_ID; +@property (nonatomic, readonly) BeeDatabaseObjectBlock LAST_RECORD; +@property (nonatomic, readonly) BeeDatabaseObjectBlockN LAST_RECORD_BY_ID; + +- (id)saveArray:(NSArray *)array; +- (id)saveDictionary:(NSDictionary *)dict; -- (void)classType:(Class)clazz; +- (id)firstRecord; +- (id)firstRecord:(NSString *)table; +- (id)firstRecordByID:(id)key; +- (id)firstRecord:(NSString *)table byID:(id)key; + +- (id)lastRecord; +- (id)lastRecord:(NSString *)table; +- (id)lastRecordByID:(id)key; +- (id)lastRecord:(NSString *)table byID:(id)key; - (NSArray *)getRecords; - (NSArray *)getRecords:(NSString *)table; @@ -96,4 +103,3 @@ typedef BOOL (^BeeActiveRecordBoolBlock)( void ); - (NSArray *)getRecords:(NSString *)table limit:(NSUInteger)limit offset:(NSUInteger)offset; @end - diff --git a/BeeFramework/Core/Storage/Bee_ActiveRecord.m b/BeeFramework/Core/Storage/Bee_ActiveRecord.m new file mode 100644 index 0000000..1a6fd17 --- /dev/null +++ b/BeeFramework/Core/Storage/Bee_ActiveRecord.m @@ -0,0 +1,1862 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_ActiveRecord.h +// + +#import "Bee_Precompile.h" +#import "Bee_Log.h" +#import "Bee_Runtime.h" +#import "Bee_UnitTest.h" + +#import "NSObject+BeeTypeConversion.h" +#import "NSDictionary+BeeExtension.h" +#import "NSNumber+BeeExtension.h" +#import "NSObject+BeeDatabase.h" + +#import "Bee_Database.h" +#import "Bee_ActiveBase.h" +#import "Bee_ActiveRecord.h" + +#import "JSONKit.h" + +#include + +#pragma mark - + +#undef __USE_ID_AS_KEY__ +#define __USE_ID_AS_KEY__ (1) + +#undef __USE_FIRST_AS_KEY__ +#define __USE_FIRST_AS_KEY__ (1) + +#undef __USE_JSON_DEFAULT__ +#define __USE_JSON_DEFAULT__ (1) + +#pragma mark - + +@interface BeeActiveRecord() +- (void)initSelf; +- (void)setObservers; +- (void)setPropertiesFrom:(NSDictionary *)dict; ++ (void)setAssociateConditions; ++ (void)setHasConditions; +@end + +#pragma mark - + +@implementation BeeActiveRecord + +@dynamic primaryKey; +@dynamic primaryID; + +@dynamic EXISTS; +@dynamic LOAD; +@dynamic SAVE; +@dynamic INSERT; +@dynamic UPDATE; +@dynamic DELETE; + +@synthesize changed = _changed; +@synthesize deleted = _deleted; + +@dynamic JSON; +@dynamic JSONData; +@dynamic JSONString; + ++ (BeeDatabase *)DB +{ + BeeDatabase * db = super.DB.CLASS_TYPE( self ); + if ( db ) + { + [self prepareOnceWithRootClass:[BeeActiveRecord class]]; + } + return db; +} + ++ (NSString *)activePrimaryKeyFor:(Class)clazz +{ + NSString * key = [super activePrimaryKeyFor:clazz]; + if ( nil == key ) + { + key = @"id"; + } + + return key; +} + ++ (NSString *)activeJSONKeyFor:(Class)clazz +{ + NSString * key = [super activeJSONKeyFor:clazz]; + if ( nil == key ) + { + key = @"JSON"; + } + + return key; +} + ++ (void)mapRelation +{ + BOOL foundPrimaryKey = NO; + + for ( Class clazzType = self;; ) + { + NSUInteger propertyCount = 0; + objc_property_t * properties = class_copyPropertyList( clazzType, &propertyCount ); + + for ( NSUInteger i = 0; i < propertyCount; i++ ) + { + const char * name = property_getName(properties[i]); + NSString * propertyName = [NSString stringWithCString:name encoding:NSUTF8StringEncoding]; + + if ( [propertyName hasSuffix:@"_"] ) + continue; + + const char * attr = property_getAttributes(properties[i]); + NSUInteger type = [BeeTypeEncoding typeOf:attr]; + + NSString * className = nil; + BOOL isActiveRecord = NO; + + NSObject * defaultValue = nil; + BOOL isPrimaryKey = NO; + + if ( BeeTypeEncoding.NSNUMBER == type ) + { + #if defined(__USE_ID_AS_KEY__) && __USE_ID_AS_KEY__ + if ( NO == foundPrimaryKey && NSOrderedSame == [propertyName compare:@"id" options:NSCaseInsensitiveSearch] ) + { + isPrimaryKey = YES; + foundPrimaryKey = YES; + } + #endif // #if defined(__USE_ID_AS_KEY__) && __USE_ID_AS_KEY__ + + #if defined(__USE_FIRST_AS_KEY__) && __USE_FIRST_AS_KEY__ + if ( NO == foundPrimaryKey ) + { + isPrimaryKey = YES; + foundPrimaryKey = YES; + } + #endif // #if defined(__USE_FIRST_AS_KEY__) && __USE_FIRST_AS_KEY__ + + if ( isPrimaryKey ) + { + defaultValue = nil; // __INT(-1); + } + else + { + defaultValue = __INT(0); + } + } + else if ( BeeTypeEncoding.NSSTRING == type ) + { + defaultValue = @""; + } + else if ( BeeTypeEncoding.NSDATE == type ) + { + defaultValue = [NSDate dateWithTimeIntervalSince1970:0]; + } +// else if ( BeeTypeEncoding.NSARRAY == type ) +// { +// defaultValue = @""; +// } +// else if ( BeeTypeEncoding.NSDICTIONARY == type ) +// { +// defaultValue = @""; +// } + else if ( BeeTypeEncoding.OBJECT == type ) + { + defaultValue = __INT(0); // 嵌套的AR对象的主键 + + className = [BeeTypeEncoding classNameOf:attr]; + + Class class = NSClassFromString( className ); + if ( [class isSubclassOfClass:[BeeActiveRecord class]] ) + { + isActiveRecord = YES; + } + } + else + { + defaultValue = @""; + } + + if ( isActiveRecord ) + { + [self mapProperty:propertyName forClass:className atPath:nil defaultValue:defaultValue]; + } + else + { + if ( isPrimaryKey ) + { + [self mapPropertyAsKey:propertyName atPath:nil defaultValue:defaultValue]; + } + else + { + [self mapProperty:propertyName atPath:nil defaultValue:defaultValue]; + } + } + } + + clazzType = class_getSuperclass( clazzType ); + if ( nil == clazzType || clazzType == [BeeActiveRecord class] ) + break; + } +} + +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context +{ + if ( _deleted ) + return; + + NSDictionary * property = (NSDictionary *)context; + if ( nil == property ) + return; + + static BOOL __enterred = NO; + if ( NO == __enterred ) + { + __enterred = YES; + + NSObject * obj1 = [change objectForKey:@"new"]; + NSObject * obj2 = [change objectForKey:@"old"]; + + if ( NO == [obj1 isEqual:obj2] ) + { + _changed = YES; + } + + NSString * name = [property objectForKey:@"name"]; + NSString * path = [property objectForKey:@"path"]; + NSNumber * type = [property objectForKey:@"type"]; + + NSObject * value = [change objectForKey:@"new"]; // [self valueForKey:name]; + + if ( object == self ) + { + // sync property to JSON + + // NSObject * value = [self valueForKey:name]; + if ( value && NO == [value isKindOfClass:[NonValue class]] ) + { + if ( BeeTypeEncoding.NSNUMBER == type.intValue ) + { + value = [value asNSNumber]; + } + else if ( BeeTypeEncoding.NSSTRING == type.intValue ) + { + value = [value asNSString]; + } + else if ( BeeTypeEncoding.NSDATE == type.intValue ) + { + value = [value asNSString]; + } + else if ( BeeTypeEncoding.OBJECT == type.intValue ) + { + // 如果嵌套的AR对象变了,对应替换掉整个JSON + + if ( [value isKindOfClass:[BeeActiveRecord class]] ) + { + value = [(BeeActiveRecord *)value JSON]; + } + else + { + value = nil; + } + } + } + + if ( path && value ) + { + [_JSON setObject:value atPath:path]; + } + } + else if ( object == _JSON ) + { + // sync JSON to property + + // NSObject * value = [_JSON objectAtPath:path]; + if ( value ) + { + if ( BeeTypeEncoding.NSNUMBER == type.intValue ) + { + value = [value asNSNumber]; + } + else if ( BeeTypeEncoding.NSSTRING == type.intValue ) + { + value = [value asNSString]; + } + else if ( BeeTypeEncoding.NSDATE == type.intValue ) + { + value = [value asNSDate]; + } + else if ( BeeTypeEncoding.OBJECT == type.intValue ) + { + // 如果嵌套的JSON对象变了,对应替换AR对象 + + NSString * className = [property objectForKey:@"className"]; + if ( className ) + { + Class class = NSClassFromString( className ); + if ( [class isSubclassOfClass:[BeeActiveRecord class]] ) + { + value = [class recordWithObject:value]; + } + else + { + value = nil; + } + } + else + { + value = nil; + } + } + } + + [self setValue:value forKey:name]; + } + + __enterred = NO; + } +} + +- (void)initSelf +{ + [[self class] prepareOnceWithRootClass:[BeeActiveRecord class]]; + +#if !defined(__USE_JSON_DEFAULT__) || (!__USE_JSON_DEFAULT__) + if ( [[self class] usingJSON] ) +#endif // #if !defined(__USE_JSON_DEFAULT__) || (!__USE_JSON_DEFAULT__) + { + _JSON = [[NSMutableDictionary alloc] init]; + } + + _changed = NO; + _deleted = NO; + + NSMutableDictionary * propertySet = self.activePropertySet; + NSString * primaryKey = self.activePrimaryKey; + NSString * JSONKey = self.activeJSONKey; + + [self setValue:[NSNumber numberWithInt:-1] forKey:primaryKey]; + + if ( _JSON ) + { + NSDictionary * property = [propertySet objectForKey:JSONKey]; + if ( property ) + { + NSString * path = [property objectForKey:@"path"]; + [_JSON setObject:[NSNumber numberWithInt:-1] atPath:path]; + } + } + + if ( propertySet && propertySet.count ) + { + for ( NSString * key in propertySet.allKeys ) + { + NSDictionary * property = [propertySet objectForKey:key]; + + NSString * name = [property objectForKey:@"name"]; + NSString * path = [property objectForKey:@"path"]; + NSNumber * type = [property objectForKey:@"type"]; + + NSObject * json = nil; + NSObject * value = [property objectForKey:@"value"]; + if ( value && NO == [value isKindOfClass:[NonValue class]] ) + { + if ( value ) + { + if ( BeeTypeEncoding.NSNUMBER == type.intValue ) + { + value = [value asNSNumber]; + json = value; + } + else if ( BeeTypeEncoding.NSSTRING == type.intValue ) + { + value = [value asNSString]; + json = value; + } + else if ( BeeTypeEncoding.NSDATE == type.intValue ) + { + value = [value asNSString]; + json = value; + } + else if ( BeeTypeEncoding.OBJECT == type.intValue ) + { + BeeActiveRecord * arValue = nil; + + // 尝试创建默认的AR对象 + NSString * className = [property objectForKey:@"className"]; + if ( className ) + { + Class class = NSClassFromString( className ); + if ( [class isSubclassOfClass:[BeeActiveRecord class]] ) + { + NSNumber * primaryKey = [value asNSNumber]; + if ( primaryKey && primaryKey.unsignedIntValue ) + { + arValue = [class recordWithKey:[value asNSNumber]]; + } + else + { + arValue = [class record]; + } + } + } + + value = arValue; + json = [arValue JSON]; + } + } + + [self setValue:value forKey:name]; + + if ( json ) + { + [_JSON setObject:json atPath:path]; + } +// else +// { +// [_JSON setObject:nil atPath:path]; +// } + } + } + } +} + +- (void)setObservers +{ + NSMutableDictionary * propertySet = self.activePropertySet; + if ( propertySet && propertySet.count ) + { + for ( NSString * key in propertySet.allKeys ) + { + NSDictionary * property = [propertySet objectForKey:key]; + + NSString * name = [property objectForKey:@"name"]; + NSString * path = [property objectForKey:@"path"]; + + [self addObserver:self + forKeyPath:name + options:NSKeyValueObservingOptionNew//|NSKeyValueObservingOptionOld + context:property]; + + [_JSON addObserver:self + forKeyPath:path + options:NSKeyValueObservingOptionNew//|NSKeyValueObservingOptionOld + context:property]; + } + } +} + +- (void)removeObservers +{ + NSMutableDictionary * propertySet = self.activePropertySet; + if ( propertySet && propertySet.count ) + { + for ( NSString * key in propertySet.allKeys ) + { + NSDictionary * property = [propertySet objectForKey:key]; + + NSString * name = [property objectForKey:@"name"]; + NSString * path = [property objectForKey:@"path"]; + + [self removeObserver:self forKeyPath:name]; + [_JSON removeObserver:self forKeyPath:path]; + } + } +} + +- (id)init +{ + self = [super init]; + if ( self ) + { + [self initSelf]; + + [self setObservers]; + [self load]; + } + return self; +} + +- (id)initWithObject:(NSObject *)object +{ + self = [super init]; + if ( self ) + { + [self initSelf]; + + if ( [object isKindOfClass:[NSNumber class]] ) + { + BeeDatabase * db = [self class].DB; + if ( db ) + { + db.WHERE( self.primaryKey, object ).GET(); + if ( db.succeed ) + { + NSObject * obj = [db.resultArray objectAtIndex:0]; + if ( [obj isKindOfClass:[NSDictionary class]] ) + { + [self setDictionary:(NSDictionary *)obj]; + } + } + } + } + else if ( [object isKindOfClass:[NSString class]] ) + { + NSString * json = [(NSString *)object stringByReplacingOccurrencesOfString:@"'" withString:@"\""]; + NSObject * dict = [json objectFromJSONString]; + if ( dict && [dict isKindOfClass:[NSDictionary class]] ) + { + [self setDictionary:(NSDictionary *)dict]; + } + } + else if ( [object isKindOfClass:[NSData class]] ) + { + NSObject * dict = [(NSData *)object objectFromJSONData]; + if ( dict && [dict isKindOfClass:[NSDictionary class]] ) + { + [self setDictionary:(NSDictionary *)dict]; + } + } + else if ( [object isKindOfClass:[NSDictionary class]] ) + { + [self setDictionary:(NSDictionary *)object]; + } + else if ( [object isKindOfClass:[BeeActiveRecord class]] ) + { + [self setDictionary:((BeeActiveRecord *)object).JSON]; + } + else + { + CC( @"Unknown object type" ); + } + + [self setObservers]; + [self load]; + } + return self; +} + +- (id)initWithDictionary:(NSDictionary *)otherDictionary +{ + self = [super init]; + if ( self ) + { + [self initSelf]; + [self setDictionary:otherDictionary]; + + [self setObservers]; + [self load]; + } + return self; +} + +- (id)initWithJSONData:(NSData *)data +{ + self = [super init]; + if ( self ) + { + [self initSelf]; + + NSObject * object = [data objectFromJSONData]; + if ( object && [object isKindOfClass:[NSDictionary class]] ) + { + [self setDictionary:(NSDictionary *)object]; + } + + [self setObservers]; + [self load]; + } + return self; +} + +- (id)initWithJSONString:(NSString *)string +{ + self = [super init]; + if ( self ) + { + [self initSelf]; + + NSObject * object = [string objectFromJSONString]; + if ( object && [object isKindOfClass:[NSDictionary class]] ) + { + [self setDictionary:(NSDictionary *)object]; + } + + [self setObservers]; + [self load]; + } + return self; +} + ++ (id)record +{ + return [[[[self class] alloc] init] autorelease]; +} + ++ (id)record:(NSObject *)otherObject +{ + if ( [otherObject isKindOfClass:[NSNull class]] ) + return nil; + + return [[[[self class] alloc] initWithObject:otherObject] autorelease]; +} + ++ (id)recordWithKey:(NSNumber *)key +{ + if ( nil == key ) + return nil; + + return [[[[self class] alloc] initWithObject:key] autorelease]; +} + ++ (id)recordWithObject:(NSObject *)otherObject +{ + if ( [otherObject isKindOfClass:[NSNull class]] ) + return nil; + + return [[[[self class] alloc] initWithObject:otherObject] autorelease]; +} + ++ (id)recordWithDictionary:(NSDictionary *)dict +{ + return [[[[self class] alloc] initWithDictionary:dict] autorelease]; +} + ++ (id)recordWithJSONData:(NSData *)data +{ + return [[[[self class] alloc] initWithJSONData:data] autorelease]; +} + ++ (id)recordWithJSONString:(NSString *)string +{ + return [[[[self class] alloc] initWithJSONString:string] autorelease]; +} + +- (void)load +{ + +} + +- (void)unload +{ + +} + +- (void)dealloc +{ +// [self update]; + + [self unload]; + [self removeObservers]; + + [_JSON release]; + + [super dealloc]; +} + +- (id)valueForUndefinedKey:(NSString *)key +{ + return nil; +} + +- (void)setValue:(id)value forUndefinedKey:(NSString *)key +{ + CC( @"[ERROR] undefined key '%@'", key ); +} + +- (NSString *)description +{ + NSMutableString * desc = [NSMutableString string]; + NSMutableDictionary * propertySet = self.activePropertySet; + + [desc appendFormat:@"%s(%p) = { ", class_getName( [self class] ), self]; + + BOOL first = YES; + + for ( NSString * key in propertySet.allKeys ) + { + NSDictionary * property = [propertySet objectForKey:key]; + + NSString * name = [property objectForKey:@"name"]; + NSNumber * type = [property objectForKey:@"type"]; + + NSObject * value = [self valueForKey:name]; + if ( value && NO == [value isKindOfClass:[NonValue class]] ) + { + if ( NO == first ) + { + [desc appendFormat:@", "]; + } + + if ( BeeTypeEncoding.NSNUMBER == type.intValue ) + { + value = [value asNSNumber]; + + [desc appendFormat:@"'%@' : %@", name, value]; + } + else if ( BeeTypeEncoding.NSSTRING == type.intValue ) + { + value = [value asNSString]; + + [desc appendFormat:@"'%@' : '%@'", name, value]; + } + else if ( BeeTypeEncoding.NSDATE == type.intValue ) + { + value = [value asNSDate]; + + [desc appendFormat:@"'%@' : '%@'", name, value]; + } + else + { +// value = [value asNSNumber]; + + [desc appendFormat:@"'%@' : <%@>", name, value]; + } + + first = NO; + } + } + + [desc appendFormat:@" }"]; + + return desc; +} + ++ (void)setAssociateConditions +{ + NSMutableDictionary * propertySet = [[self class] activePropertySet]; + + for ( NSString * key in propertySet.allKeys ) + { + NSDictionary * property = [propertySet objectForKey:key]; + + NSString * name = [property objectForKey:@"name"]; + NSNumber * type = [property objectForKey:@"type"]; + + NSString * associateClass = [property objectForKey:@"associateClass"]; + NSString * associateProperty = [property objectForKey:@"associateProperty"]; + + NSMutableArray * values = [NSMutableArray array]; + + if ( associateClass ) + { + Class classType = NSClassFromString( associateClass ); + if ( classType ) + { + NSArray * objs = [super.DB associateObjectsFor:classType]; + for ( NSObject * obj in objs ) + { + if ( associateProperty ) + { + NSObject * value = [obj valueForKey:associateProperty]; + [values addObject:value]; + } + else + { + NSObject * value = [obj valueForKey:classType.activePrimaryKey]; + [values addObject:value]; + } + } + } + } + + for ( NSObject * value in values ) + { + if ( value && NO == [value isKindOfClass:[NonValue class]] ) + { + if ( BeeTypeEncoding.NSNUMBER == type.intValue ) + { + value = [value asNSNumber]; + } + else if ( BeeTypeEncoding.NSSTRING == type.intValue ) + { + value = [value asNSString]; + } + else if ( BeeTypeEncoding.NSDATE == type.intValue ) + { + value = [[value asNSDate] description]; + } + else + { + // value = [value asNSNumber]; + } + + super.DB.WHERE( name, value ); + } + } + } +} + ++ (void)setHasConditions +{ + // TODO: + + NSMutableDictionary * propertySet = [[self class] activePropertySet]; + + for ( NSString * key in propertySet.allKeys ) + { + NSDictionary * property = [propertySet objectForKey:key]; + + NSString * name = [property objectForKey:@"name"]; + NSNumber * type = [property objectForKey:@"type"]; + NSString * className = [property objectForKey:@"className"]; + + if ( BeeTypeEncoding.OBJECT != type.intValue ) + continue; + + NSMutableArray * values = [NSMutableArray array]; + + if ( className ) + { + Class classType = NSClassFromString( className ); + if ( classType ) + { + NSArray * objs = [super.DB hasObjectsFor:classType]; + for ( NSObject * obj in objs ) + { + NSObject * value = [obj valueForKey:name]; + [values addObject:value]; + } + } + } + + for ( NSObject * value in values ) + { + if ( [value isKindOfClass:[BeeActiveRecord class]] ) + { + BeeActiveRecord * record = (BeeActiveRecord *)value; + value = record.primaryID; + } + + if ( value ) + { + super.DB.WHERE( name, value ); + } + } + } +} + +- (void)setPropertiesFrom:(NSDictionary *)dict +{ + NSMutableDictionary * propertySet = self.activePropertySet; + NSString * primaryKey = self.activePrimaryKey; + NSString * JSONKey = self.activeJSONKey; + +// reset primary key + + [self setValue:[NSNumber numberWithInt:-1] forKey:primaryKey]; + +// reset properties + + for ( NSString * key in propertySet.allKeys ) + { + NSDictionary * property = [propertySet objectForKey:key]; + + NSString * name = [property objectForKey:@"name"]; + if ( [name isEqualToString:JSONKey] ) + continue; + + [self setValue:nil forKey:name]; + } + +// reset JSON + + [_JSON removeAllObjects]; + +// reset inner AR objects + + for ( NSString * key in propertySet.allKeys ) + { + NSDictionary * property = [propertySet objectForKey:key]; + NSNumber * type = [property objectForKey:@"type"]; + + if ( BeeTypeEncoding.OBJECT == type.intValue ) + { + NSString * name = [property objectForKey:@"name"]; + NSObject * value = [self valueForKey:name]; + + if ( value && [value isKindOfClass:[BeeActiveRecord class]] ) + { + BeeActiveRecord * record = (BeeActiveRecord *)value; + [record setPropertiesFrom:nil]; + } + } + } + + if ( nil == dict ) + return; + +// set properties + + for ( NSString * key in propertySet.allKeys ) + { + NSDictionary * property = [propertySet objectForKey:key]; + + NSString * name = [property objectForKey:@"name"]; + NSString * path = [property objectForKey:@"path"]; + NSNumber * type = [property objectForKey:@"type"]; + + NSString * associateClass = [property objectForKey:@"associateClass"]; + NSString * associateProperty = [property objectForKey:@"associateProperty"]; + + NSMutableArray * values = [NSMutableArray array]; + + if ( associateClass ) + { + Class classType = NSClassFromString( associateClass ); + if ( classType ) + { + NSArray * objs = [super.DB associateObjectsFor:classType]; + for ( NSObject * obj in objs ) + { + if ( associateProperty ) + { + NSObject * value = [obj valueForKey:associateProperty]; + [values addObject:value]; + } + else + { + NSObject * value = [obj valueForKey:classType.activePrimaryKey]; + [values addObject:value]; + } + } + } + } + + NSObject * value = values.count ? values.lastObject : nil; + + if ( nil == value ) + { + value = [dict objectAtPath:path]; + } + + if ( value && NO == [value isKindOfClass:[NonValue class]] ) + { + if ( BeeTypeEncoding.NSNUMBER == type.intValue ) + { + value = [value asNSNumber]; + } + else if ( BeeTypeEncoding.NSSTRING == type.intValue ) + { + value = [value asNSString]; + } + else if ( BeeTypeEncoding.NSDATE == type.intValue ) + { + value = [value asNSDate]; + } + else if ( BeeTypeEncoding.OBJECT == type.intValue ) + { + // set inner AR objects + + BeeActiveRecord * record = nil; + + NSString * className = [property objectForKey:@"className"]; + if ( className ) + { + Class class = NSClassFromString( className ); + if ( [class isSubclassOfClass:[BeeActiveRecord class]] ) + { + record = [class recordWithObject:value]; + } + } + + value = record; + } + else + { +// value = [value asNSNumber]; + } + + if ( name && value ) + { + [self setValue:value forKey:name]; + } + } + } + +// reset flags + + _changed = YES; + _deleted = NO; +} + +- (void)setDictionary:(NSDictionary *)dict +{ + [self setPropertiesFrom:dict]; + + [_JSON setDictionary:dict]; +} + +- (NSDictionary *)JSON +{ + return _JSON; +} + +- (void)setJSON:(NSMutableDictionary *)JSON +{ + [self setDictionary:JSON]; +} + +- (NSData *)JSONData +{ + return [_JSON JSONData]; +} + +- (void)setJSONData:(NSData *)data +{ + NSObject * object = [data objectFromJSONData]; + if ( object && [object isKindOfClass:[NSDictionary class]] ) + { + [self setDictionary:(NSDictionary *)object]; + } +} + +- (NSString *)JSONString +{ + NSString * json = [_JSON JSONString]; + + if ( json ) + { + json = [json stringByReplacingOccurrencesOfString:@"\\\\\\\"" withString:@"\""]; + json = [json stringByReplacingOccurrencesOfString:@"\\\"" withString:@"\""]; + } + + return json; +} + +- (void)setJSONString:(NSString *)string +{ + NSObject * object = [string objectFromJSONString]; + if ( object && [object isKindOfClass:[NSDictionary class]] ) + { + [self setDictionary:(NSDictionary *)object]; + } +} + +- (NSString *)primaryKey +{ + return self.activePrimaryKey; +} + +- (NSNumber *)primaryID +{ + return [self valueForKey:self.activePrimaryKey]; +} + +- (void)setPrimaryID:(NSNumber *)pid +{ + [self setValue:(pid ? pid : [NSNumber numberWithInt:-1]) + forKey:self.activePrimaryKey]; +} + +- (BOOL)get +{ + NSString * primaryKey = self.activePrimaryKey; + NSNumber * primaryID = [self valueForKey:primaryKey]; + if ( nil == primaryID || primaryID.intValue < 0 ) + return NO; + + super.DB + .FROM( self.tableName ) + .WHERE( primaryKey, [self valueForKey:primaryKey] ) + .LIMIT( 1 ) + .GET(); + + if ( super.DB.succeed ) + { + NSDictionary * dict = [super.DB.resultArray objectAtIndex:0]; + if ( dict ) + { + [self setPropertiesFrom:dict]; + + NSString * json = [dict objectForKey:self.activeJSONKey]; + if ( json && json.length ) + { + NSObject * object = [json objectFromJSONString]; + if ( object && [object isKindOfClass:[NSDictionary class]] ) + { + [_JSON removeAllObjects]; + [_JSON setDictionary:(NSDictionary *)object]; + } + } + + return YES; + } + } + + return NO; +} + +- (BOOL)exists +{ + NSString * primaryKey = self.activePrimaryKey; + NSNumber * primaryID = [self valueForKey:primaryKey]; + if ( nil == primaryID || primaryID.intValue < 0 ) + return NO; + + super.DB + .FROM( self.tableName ) + .WHERE( primaryKey, [self valueForKey:primaryKey] ) + .LIMIT( 1 ) + .COUNT(); + + if ( super.DB.succeed && super.DB.resultCount > 0 ) + { + return YES; + } + + return NO; +} + +- (BOOL)insert +{ + if ( _deleted ) + return NO; + +// if already inserted into table, no nessecery insert again + + NSString * primaryKey = self.activePrimaryKey; + NSNumber * primaryID = [self valueForKey:primaryKey]; + + if ( primaryID && primaryID.intValue >= 0 ) + return NO; + + NSString * JSONKey = self.activeJSONKey; + NSDictionary * propertySet = self.activePropertySet; + +// step 1, save inner AR objects + + for ( NSString * key in propertySet.allKeys ) + { + NSDictionary * property = [propertySet objectForKey:key]; + NSNumber * type = [property objectForKey:@"type"]; + + if ( BeeTypeEncoding.OBJECT == type.intValue ) + { + NSString * name = [property objectForKey:@"name"]; + NSObject * value = [self valueForKey:name]; + + if ( value && [value isKindOfClass:[BeeActiveRecord class]] ) + { + BeeActiveRecord * record = (BeeActiveRecord *)value; + [record exists] ? [record update] : [record insert]; + } + } + } + +// step 2, save this object + + super.DB.FROM( self.tableName ); + + for ( NSString * key in propertySet.allKeys ) + { + NSDictionary * property = [propertySet objectForKey:key]; + + NSString * name = [property objectForKey:@"name"]; + NSNumber * type = [property objectForKey:@"type"]; + + if ( [name isEqualToString:JSONKey] || [name isEqualToString:primaryKey] ) + continue; + + NSObject * value = [self valueForKey:name]; + if ( value ) + { + if ( BeeTypeEncoding.NSNUMBER == type.intValue ) + { + value = [value asNSNumber]; + } + else if ( BeeTypeEncoding.NSSTRING == type.intValue ) + { + value = [value asNSString]; + } + else if ( BeeTypeEncoding.NSDATE == type.intValue ) + { + value = [[value asNSDate] description]; + } + else if ( BeeTypeEncoding.OBJECT == type.intValue ) + { + if ( [value isKindOfClass:[BeeActiveRecord class]] ) + { + BeeActiveRecord * record = (BeeActiveRecord *)value; + NSString * primaryKey = [value class].activePrimaryKey; + + value = [record valueForKey:primaryKey]; + } + else + { + value = nil; + } + } + else + { +// value = [value asNSNumber]; + } + + if ( name && value ) + { + super.DB.SET( name, value ); + } + } + } + + if ( [[self class] usingJSON] ) + { + super.DB.SET( self.activeJSONKey, self.JSONString ); + } + + super.DB.INSERT(); + + if ( super.DB.succeed ) + { + _changed = NO; + + [self setValue:[NSNumber numberWithInt:super.DB.insertID] forKey:primaryKey]; + return YES; + } + + return NO; +} + +- (BOOL)update +{ + if ( _deleted || NO == _changed ) + return NO; + +// if already inserted into table, no nessecery insert again + + NSString * primaryKey = self.activePrimaryKey; + NSNumber * primaryID = [self valueForKey:primaryKey]; + + if ( primaryID && primaryID.intValue < 0 ) + return NO; + + NSString * JSONKey = self.activeJSONKey; + NSDictionary * propertySet = self.activePropertySet; + +// step 1, update inner AR objects + + for ( NSString * key in propertySet.allKeys ) + { + NSDictionary * property = [propertySet objectForKey:key]; + NSNumber * type = [property objectForKey:@"type"]; + + if ( BeeTypeEncoding.OBJECT == type.intValue ) + { + NSString * name = [property objectForKey:@"name"]; + NSObject * value = [self valueForKey:name]; + + if ( value && [value isKindOfClass:[BeeActiveRecord class]] ) + { + BeeActiveRecord * record = (BeeActiveRecord *)value; + [record exists] ? [record update] : [record insert]; + } + } + } + +// step 2, update this object + + super.DB + .FROM( self.tableName ) + .WHERE( primaryKey, primaryID ); + + for ( NSString * key in propertySet.allKeys ) + { + NSDictionary * property = [propertySet objectForKey:key]; + + NSString * name = [property objectForKey:@"name"]; + NSNumber * type = [property objectForKey:@"type"]; + + if ( [name isEqualToString:JSONKey] || [name isEqualToString:primaryKey] ) + continue; + + NSObject * value = [self valueForKey:name]; + if ( value ) + { + if ( BeeTypeEncoding.NSNUMBER == type.intValue ) + { + value = [value asNSNumber]; + } + else if ( BeeTypeEncoding.NSSTRING == type.intValue ) + { + value = [value asNSString]; + } + else if ( BeeTypeEncoding.NSDATE == type.intValue ) + { + value = [[value asNSDate] description]; + } + else if ( BeeTypeEncoding.OBJECT == type.intValue ) + { + if ( [value isKindOfClass:[BeeActiveRecord class]] ) + { + BeeActiveRecord * record = (BeeActiveRecord *)value; + NSString * primaryKey = [value class].activePrimaryKey; + + value = [record valueForKey:primaryKey]; + } + else + { + value = nil; + } + } + else + { +// value = [value asNSNumber]; + } + + super.DB.SET( name, value ); + } + } + + if ( [[self class] usingJSON] ) + { + super.DB.SET( self.activeJSONKey, self.JSONString ); + } + + super.DB.UPDATE(); + + if ( super.DB.succeed ) + { + _changed = NO; + return YES; + } + + return NO; +} + +- (BOOL)delete +{ + if ( _deleted ) + return NO; + + NSString * JSONKey = self.activeJSONKey; + NSString * primaryKey = self.activePrimaryKey; + NSObject * primaryID = [self valueForKey:primaryKey]; + NSDictionary * propertySet = self.activePropertySet; + + super.DB + .FROM( self.tableName ) + .WHERE( primaryKey, primaryID ) + .DELETE(); + + if ( super.DB.succeed ) + { + [self setValue:[NSNumber numberWithInt:-1] forKey:primaryKey]; + + for ( NSString * key in propertySet.allKeys ) + { + NSDictionary * property = [propertySet objectForKey:key]; + + NSString * name = [property objectForKey:@"name"]; + if ( [name isEqualToString:JSONKey] ) + continue; + + NSObject * value = [property objectForKey:@"value"]; + if ( value && NO == [value isKindOfClass:[NonValue class]] ) + { + [self setValue:value forKey:name]; + } + else + { + [self setValue:nil forKey:name]; + } + } + + [_JSON removeAllObjects]; + + _changed = NO; + _deleted = YES; + +// // 将嵌套的AR对象也删一遍 +// +// for ( NSString * key in propertySet.allKeys ) +// { +// NSDictionary * property = [propertySet objectForKey:key]; +// NSNumber * type = [property objectForKey:@"type"]; +// +// if ( BeeTypeEncoding.OBJECT == type.intValue ) +// { +// NSString * name = [property objectForKey:@"name"]; +// NSObject * value = [self valueForKey:name]; +// +// if ( value && [value isKindOfClass:[BeeActiveRecord class]] ) +// { +// BeeActiveRecord * record = (BeeActiveRecord *)value; +// [record delete]; +// } +// } +// } + + return YES; + } + + return NO; +} + +- (BeeDatabaseBoolBlock)EXISTS +{ + BeeDatabaseBoolBlock block = ^ BOOL ( void ) + { + return [self exists]; + }; + + return [[block copy] autorelease]; +} + +- (BeeDatabaseBoolBlock)INSERT +{ + BeeDatabaseBoolBlock block = ^ BOOL ( void ) + { + return [self insert]; + }; + + return [[block copy] autorelease]; +} + +- (BeeDatabaseBoolBlock)UPDATE +{ + BeeDatabaseBoolBlock block = ^ BOOL ( void ) + { + return [self update]; + }; + + return [[block copy] autorelease]; +} + +- (BeeDatabaseBoolBlock)DELETE +{ + BeeDatabaseBoolBlock block = ^ BOOL ( void ) + { + return [self delete]; + }; + + return [[block copy] autorelease]; +} + +- (BeeDatabaseBoolBlock)LOAD +{ + BeeDatabaseBoolBlock block = ^ BOOL ( void ) + { + return [self get]; + + return YES; + }; + + return [[block copy] autorelease]; +} + +- (BeeDatabaseBoolBlock)SAVE +{ + BeeDatabaseBoolBlock block = ^ BOOL ( void ) + { + BOOL ret = [self exists]; + if ( NO == ret ) + { + ret = [self insert]; + } + else + { + ret = [self update]; + } + return ret; + }; + + return [[block copy] autorelease]; +} + +@end + +#pragma mark - + +@implementation NSArray(BeeActiveRecord) + +- (NSArray *)activeRecordsFromArray:(Class)clazz +{ + NSMutableArray * array = [NSMutableArray array]; + + for ( NSObject * obj in self ) + { + if ( [obj isKindOfClass:[NSDictionary class]] ) + { + BeeActiveRecord * record = [(NSDictionary *)obj activeRecordFromDictionary:clazz]; + if ( record ) + { + [array addObject:record]; + } + } + } + + return array; +} + +@end + +#pragma mark - + +@implementation NSDictionary(BeeActiveRecord) + +- (BeeActiveRecord *)activeRecordFromDictionary:(Class)clazz +{ + if ( NO == [clazz isSubclassOfClass:[BeeActiveRecord class]] ) + return nil; + + return [[[clazz alloc] initWithDictionary:self] autorelease]; +} + +@end + +#pragma mark - + +@implementation BeeDatabase(BeeActiveRecord) + +@dynamic BELONG_TO; +@dynamic HAS; + +@dynamic SAVE; +@dynamic SAVE_ARRAY; +@dynamic SAVE_DICTIONARY; + +@dynamic GET_RECORDS; +@dynamic FIRST_RECORD; +@dynamic FIRST_RECORD_BY_ID; +@dynamic LAST_RECORD; +@dynamic LAST_RECORD_BY_ID; + +- (BeeDatabaseBlockN)BELONG_TO +{ + BeeDatabaseBlockN block = ^ BeeDatabase * ( id first, ... ) + { + return self.ASSOCIATE( first ); + }; + + return [[block copy] autorelease]; +} + +- (BeeDatabaseBlockN)HAS +{ + BeeDatabaseBlockN block = ^ BeeDatabase * ( id first, ... ) + { + return self.ASSOCIATE( first ); + }; + + return [[block copy] autorelease]; +} + +- (BeeDatabaseBlockN)SAVE +{ + BeeDatabaseBlockN block = ^ BeeDatabase * ( id first, ... ) + { + if ( [first isKindOfClass:[NSArray class]] ) + { + return [self saveArray:(NSArray *)first]; + } + else if ( [first isKindOfClass:[NSDictionary class]] ) + { + return [self saveDictionary:(NSDictionary *)first]; + } + + return self; + }; + + return [[block copy] autorelease]; +} + +- (BeeDatabaseBlockN)SAVE_ARRAY +{ + BeeDatabaseBlockN block = ^ BeeDatabase * ( id first, ... ) + { + return [self saveArray:(NSArray *)first]; + }; + + return [[block copy] autorelease]; +} + +- (BeeDatabaseBlockN)SAVE_DICTIONARY +{ + BeeDatabaseBlockN block = ^ BeeDatabase * ( id first, ... ) + { + return [self saveDictionary:(NSDictionary *)first]; + }; + + return [[block copy] autorelease]; +} + +- (BeeDatabaseArrayBlock)GET_RECORDS +{ + BeeDatabaseArrayBlock block = ^ NSArray * ( void ) + { + return [self getRecords]; + }; + + return [[block copy] autorelease]; +} + +- (BeeDatabaseObjectBlock)FIRST_RECORD +{ + BeeDatabaseObjectBlock block = ^ NSArray * ( void ) + { + return [self firstRecord]; + }; + + return [[block copy] autorelease]; +} + +- (BeeDatabaseObjectBlockN)FIRST_RECORD_BY_ID +{ + BeeDatabaseObjectBlockN block = ^ NSArray * ( id first, ... ) + { + return [self firstRecord:nil byID:first]; + }; + + return [[block copy] autorelease]; +} + +- (BeeDatabaseObjectBlock)LAST_RECORD +{ + BeeDatabaseObjectBlock block = ^ NSArray * ( void ) + { + return [self lastRecord]; + }; + + return [[block copy] autorelease]; +} + +- (BeeDatabaseObjectBlockN)LAST_RECORD_BY_ID +{ + BeeDatabaseObjectBlockN block = ^ NSArray * ( id first, ... ) + { + return [self lastRecord:nil byID:first]; + }; + + return [[block copy] autorelease]; +} + +- (id)saveArray:(NSArray *)array +{ + self.BATCH_BEGIN(); + + for ( NSObject * obj in array ) + { + if ( NO == [obj isKindOfClass:[NSDictionary class]] ) + continue; + + [self saveDictionary:(NSDictionary *)obj]; + } + + self.BATCH_END(); + + return self; +} + +- (id)saveDictionary:(NSDictionary *)dict +{ + Class classType = self.classType; + if ( NO == [classType isSubclassOfClass:[BeeActiveRecord class]] ) + return self; + + BeeActiveRecord * record = [dict activeRecordFromDictionary:classType]; + if ( record ) + { + record.SAVE(); + } + + return self; +} + +- (id)firstRecord +{ + return [self firstRecord:nil]; +} + +- (id)firstRecord:(NSString *)table +{ + NSArray * array = [self getRecords:table limit:1 offset:0]; + if ( array && array.count ) + { + return [array objectAtIndex:0]; + } + + return nil; +} + +- (id)firstRecordByID:(id)key +{ + return [self firstRecord:nil byID:key]; +} + +- (id)firstRecord:(NSString *)table byID:(id)key +{ + if ( nil == key ) + return nil; + + [self __internalResetResult]; + + Class classType = [self classType]; + if ( NULL == classType ) + return nil; + + NSString * primaryKey = [BeeActiveRecord activePrimaryKeyFor:classType]; + if ( nil == primaryKey ) + return nil; + + [classType setAssociateConditions]; + [classType setHasConditions]; + + self.WHERE( primaryKey, key ).OFFSET( 0 ).LIMIT( 1 ).GET(); + if ( NO == self.succeed ) + return nil; + + NSArray * array = self.resultArray; + if ( nil == array || 0 == array.count ) + return nil; + + NSDictionary * dict = [array objectAtIndex:0]; + if ( dict ) + { + return [[[classType alloc] initWithDictionary:dict] autorelease]; + } + + return nil; +} + +- (id)lastRecord +{ + return [self lastRecord:nil]; +} + +- (id)lastRecord:(NSString *)table +{ + NSArray * array = [self getRecords:table limit:1 offset:0]; + if ( array && array.count ) + { + return array.lastObject; + } + + return nil; +} + +- (id)lastRecordByID:(id)key +{ + return [self lastRecord:nil byID:key]; +} + +- (id)lastRecord:(NSString *)table byID:(id)key +{ + if ( nil == key ) + return nil; + + [self __internalResetResult]; + + Class classType = [self classType]; + if ( NULL == classType ) + return nil; + + NSString * primaryKey = [BeeActiveRecord activePrimaryKeyFor:classType]; + if ( nil == primaryKey ) + return nil; + + [classType setAssociateConditions]; + [classType setHasConditions]; + + self.WHERE( primaryKey, key ).OFFSET( 0 ).LIMIT( 1 ).GET(); + if ( NO == self.succeed ) + return nil; + + NSArray * array = self.resultArray; + if ( nil == array || 0 == array.count ) + return nil; + + NSDictionary * dict = array.lastObject; + if ( dict ) + { + return [[[classType alloc] initWithDictionary:dict] autorelease]; + } + + return nil; +} + +- (NSArray *)getRecords +{ + return [self getRecords:nil limit:0 offset:0]; +} + +- (NSArray *)getRecords:(NSString *)table +{ + return [self getRecords:table limit:0 offset:0]; +} + +- (NSArray *)getRecords:(NSString *)table limit:(NSUInteger)limit +{ + return [self getRecords:table limit:limit offset:0]; +} + +- (NSArray *)getRecords:(NSString *)table limit:(NSUInteger)limit offset:(NSUInteger)offset +{ + [self __internalResetResult]; + + Class classType = [self classType]; + if ( NULL == classType ) + return [NSArray array]; + + NSString * primaryKey = [BeeActiveRecord activePrimaryKeyFor:classType]; + if ( nil == primaryKey ) + return [NSArray array]; + + [classType setAssociateConditions]; + [classType setHasConditions]; + + self.OFFSET( offset ).LIMIT( limit ).GET(); + if ( NO == self.succeed ) + return [NSArray array]; + + NSArray * array = self.resultArray; + if ( nil == array || 0 == array.count ) + return [NSArray array]; + + NSMutableArray * activeRecords = [[NSMutableArray alloc] init]; + + for ( NSDictionary * dict in array ) + { + BeeActiveRecord * object = [[[classType alloc] initWithDictionary:dict] autorelease]; + [activeRecords addObject:object]; + } + + [_resultArray removeAllObjects]; + [_resultArray addObjectsFromArray:activeRecords]; + + [activeRecords release]; + + return _resultArray; +} + +@end diff --git a/BeeFramework/Core/Storage/Bee_ActiveRecordTest.m b/BeeFramework/Core/Storage/Bee_ActiveRecordTest.m new file mode 100644 index 0000000..2d510c7 --- /dev/null +++ b/BeeFramework/Core/Storage/Bee_ActiveRecordTest.m @@ -0,0 +1,365 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_ActiveRecordTest.h +// + +#import "Bee.h" + +#if defined(__BEE_UNITTEST__) && __BEE_UNITTEST__ + +#pragma mark - + +@interface Location : BeeActiveRecord + +@property (nonatomic, retain) NSNumber * lid; +@property (nonatomic, retain) NSNumber * lat; +@property (nonatomic, retain) NSNumber * lon; + +@end + +#pragma mark - + +@implementation Location + +@synthesize lid; +@synthesize lat; +@synthesize lon; + +@end + +#pragma mark - + +@interface User : BeeActiveRecord + +@property (nonatomic, retain) NSNumber * uid; +@property (nonatomic, retain) NSString * name; +@property (nonatomic, retain) NSString * gender; +@property (nonatomic, retain) NSString * city; +@property (nonatomic, retain) NSDate * birth; + +@end + +#pragma mark - + +@implementation User + +@synthesize uid; +@synthesize name; +@synthesize gender; +@synthesize city; +@synthesize birth; + ++ (void)mapRelation +{ + [super mapRelation]; + [super useJSON]; + [super useAutoIncrement]; +} + +@end + +#pragma mark - + +@interface User2 : User + +@property (nonatomic, retain) Location * location; + +@end + +#pragma mark - + +@implementation User2 + +@synthesize location; + +@end + +#pragma mark - + +TEST_CASE(BeeActiveRecord_BeeDatabase) +{ + // Clear table + + User2.DB.EMPTY(); + + // Insert 2 records into table 'table_User2' + + User2.DB + .SET( @"name", @"gavin" ) + .SET( @"gender", @"male" ) + .INSERT(); + + User2.DB + .SET( @"name", @"amanda" ) + .SET( @"gender", @"female" ) + .SET( @"city", @"Columbus" ) + .SET( @"birth", [NSDate date] ) + .INSERT(); + + // Update records + + User2.DB + .WHERE( @"name", @"gavin" ) + .SET( @"city", @"Columbus" ) + .UPDATE(); + + // Query records + + User2.DB.WHERE( @"city", @"Columbus" ).GET(); // Results are NSDictionary + NSAssert( User2.DB.succeed, @"" ); + NSAssert( User2.DB.resultCount == 2, @"" ); + + for ( NSDictionary * dict in User2.DB.resultArray ) + { + VAR_DUMP( dict ); + } + + // Delete records + + User2.DB.WHERE( @"city", @"Columbus" ).DELETE(); + + // Count records + + User2.DB.COUNT(); + NSAssert( User2.DB.succeed, @"" ); + NSAssert( User2.DB.resultCount == 0, @"" ); +} +TEST_CASE_END + +#pragma mark - + +TEST_CASE(BeeActiveRecord) +{ +// Clear table + + User2.DB.EMPTY(); + +// test + + User2 * me; + User2 * copy; + + me = [User2 record]; + me.name = @"gavin"; // set value by property + me.city = @"beijing"; // set value by property + me.location.lat = __INT(888); + me.location.lon = __INT(999); + [me.JSON setObject:@"m" forKey:@"gender"]; // set value by JSON + [me.JSON setObject:[[NSDate date] description] forKey:@"birth"]; // set value by JSON + me.SAVE(); + + User2.DB.GET_RECORDS(); // Results are BeeActiveRecord + for ( User2 * info in User2.DB.resultArray ) + { + VAR_DUMP( info ); + } + + NSAssert( [me.name isEqualToString:@"gavin"], @"" ); // get value by property + NSAssert( [me.city isEqualToString:@"beijing"], @"" ); // get value by property + NSAssert( [me.gender isEqualToString:@"m"], @"" ); // get value by property + NSAssert( [me.location.lat isEqualToNumber:__INT(888)], @"" ); + NSAssert( [me.location.lon isEqualToNumber:__INT(999)], @"" ); + + NSAssert( [[me.JSON objectForKey:@"name"] isEqualToString:@"gavin"], @"" ); // get value by JSON + NSAssert( [[me.JSON objectForKey:@"city"] isEqualToString:@"beijing"], @"" ); // get value by JSON + NSAssert( [[me.JSON objectForKey:@"gender"] isEqualToString:@"m"], @"" ); // get value by JSON + NSAssert( [[me.JSON numberAtPath:@"location.lat"] isEqualToNumber:__INT(888)], @"" ); // get value by JSON + NSAssert( [[me.JSON numberAtPath:@"location.lon"] isEqualToNumber:__INT(999)], @"" ); // get value by JSON + + VAR_DUMP( me.JSON ); // convert object to JSON object + VAR_DUMP( me.JSONString ); // convert object to JSON string + VAR_DUMP( me.JSONData ); // convert object to JSON data + +// create by ActiveRecord + + copy = [User2 record:me]; + NSAssert( [copy.name isEqualToString:me.name], @"" ); + NSAssert( [copy.city isEqualToString:me.city], @"" ); + NSAssert( [copy.gender isEqualToString:me.gender], @"" ); + NSAssert( [copy.location.lat isEqualToNumber:__INT(888)], @"" ); + NSAssert( [copy.location.lon isEqualToNumber:__INT(999)], @"" ); + copy.SAVE(); + copy.DELETE(); + + User2.DB.GET_RECORDS(); // Results are BeeActiveRecord + for ( User2 * info in User2.DB.resultArray ) + { + VAR_DUMP( info ); + } + +// create by JSON + + copy = [User2 record:me.JSON]; + NSAssert( [copy.name isEqualToString:me.name], @"" ); + NSAssert( [copy.city isEqualToString:me.city], @"" ); + NSAssert( [copy.gender isEqualToString:me.gender], @"" ); + NSAssert( [copy.location.lat isEqualToNumber:__INT(888)], @"" ); + NSAssert( [copy.location.lon isEqualToNumber:__INT(999)], @"" ); + copy.SAVE(); + copy.DELETE(); + + User2.DB.GET_RECORDS(); // Results are BeeActiveRecord + for ( User2 * info in User2.DB.resultArray ) + { + VAR_DUMP( info ); + } + +// create by JSON String + + copy = [User2 record:me.JSONString]; + NSAssert( [copy.name isEqualToString:me.name], @"" ); + NSAssert( [copy.city isEqualToString:me.city], @"" ); + NSAssert( [copy.gender isEqualToString:me.gender], @"" ); + NSAssert( [copy.location.lat isEqualToNumber:__INT(888)], @"" ); + NSAssert( [copy.location.lon isEqualToNumber:__INT(999)], @"" ); + copy.SAVE(); + copy.DELETE(); + + User2.DB.GET_RECORDS(); // Results are BeeActiveRecord + for ( User2 * info in User2.DB.resultArray ) + { + VAR_DUMP( info ); + } + +// create by JSON Data + + copy = [User2 record:me.JSONData]; + NSAssert( [copy.name isEqualToString:me.name], @"" ); + NSAssert( [copy.city isEqualToString:me.city], @"" ); + NSAssert( [copy.gender isEqualToString:me.gender], @"" ); + NSAssert( [copy.location.lat isEqualToNumber:__INT(888)], @"" ); + NSAssert( [copy.location.lon isEqualToNumber:__INT(999)], @"" ); + copy.SAVE(); + copy.DELETE(); + + User2.DB.GET_RECORDS(); // Results are BeeActiveRecord + for ( User2 * info in User2.DB.resultArray ) + { + VAR_DUMP( info ); + } + +// create by String + + copy = [User2 record:@"{ \ + 'name' : 'gavin', \ + 'city' : 'beijing', \ + 'gender' : 'm', \ + 'location' : { 'lat' : 888, 'lid' : 100, 'lon' : 999 } \ + }"]; + NSAssert( [copy.name isEqualToString:me.name], @"" ); + NSAssert( [copy.city isEqualToString:me.city], @"" ); + NSAssert( [copy.gender isEqualToString:me.gender], @"" ); + NSAssert( [copy.location.lat isEqualToNumber:__INT(888)], @"" ); + NSAssert( [copy.location.lon isEqualToNumber:__INT(999)], @"" ); + copy.SAVE(); + copy.DELETE(); + + User2.DB.GET_RECORDS(); // Results are BeeActiveRecord + for ( User2 * info in User2.DB.resultArray ) + { + VAR_DUMP( info ); + } + + me.DELETE(); + + User2.DB.GET_RECORDS(); // Results are BeeActiveRecord + for ( User2 * info in User2.DB.resultArray ) + { + VAR_DUMP( info ); + } + +// Insert 2 records into table 'table_User2' + + User2 * record1 = [User2 record]; + record1.name = @"gavin"; + record1.gender = @"male"; + record1.SAVE(); + + VAR_DUMP( record1.JSON ); + VAR_DUMP( record1.JSONString ); + VAR_DUMP( record1.JSONData ); + + [record1.JSON setObject:@"1234" forKey:@"undefinedKey"]; + [record1.JSON setObject:@"gavin.kwoe" forKey:@"name"]; + + record1.city = @"Columbus"; + record1.SAVE(); + + User2 * record2 = [User2 record]; + record2.name = @"amanda"; + record2.gender = @"female"; + record2.city = @"Columbus"; + record2.birth = [NSDate date]; + record2.SAVE(); + + +// Query records + + User2.DB.GET_RECORDS(); // Results are BeeActiveRecord + NSAssert( User2.DB.succeed, @"" ); + NSAssert( User2.DB.resultCount > 0, @"" ); + + for ( User2 * info in User2.DB.resultArray ) + { + VAR_DUMP( info ); + } + + User2.DB.WHERE( @"city", @"Columbus" ).GET_RECORDS(); // Results are BeeActiveRecord + NSAssert( User2.DB.succeed, @"" ); + NSAssert( User2.DB.resultCount > 0, @"" ); + + for ( User2 * info in User2.DB.resultArray ) + { + VAR_DUMP( info ); + } + +// Delete records + + record1.DELETE(); + record2.DELETE(); + + User2.DB.GET_RECORDS(); // Results are BeeActiveRecord +// NSAssert( User2.DB.succeed, @"" ); +// NSAssert( User2.DB.resultCount == 0, @"" ); + + for ( User2 * info in User2.DB.resultArray ) + { + VAR_DUMP( info ); + } + +// Count records + + User2.DB.COUNT(); + NSAssert( User2.DB.succeed, @"" ); + NSAssert( User2.DB.resultCount == 0, @"" ); +} +TEST_CASE_END + +#endif // #if defined(__BEE_UNITTEST__) && __BEE_UNITTEST__ diff --git a/BeeFramework/Foundation/Bee_Cache.h b/BeeFramework/Core/Storage/Bee_Cache.h similarity index 100% rename from BeeFramework/Foundation/Bee_Cache.h rename to BeeFramework/Core/Storage/Bee_Cache.h diff --git a/BeeFramework/Foundation/Bee_Cache.m b/BeeFramework/Core/Storage/Bee_Cache.m similarity index 97% rename from BeeFramework/Foundation/Bee_Cache.m rename to BeeFramework/Core/Storage/Bee_Cache.m index 1f27a59..a9caeac 100644 --- a/BeeFramework/Foundation/Bee_Cache.m +++ b/BeeFramework/Core/Storage/Bee_Cache.m @@ -302,9 +302,12 @@ - (void)deleteAll - (void)handleNotification:(NSNotification *)notification { - if ( _clearWhenMemoryLow ) + if ( [notification is:UIApplicationDidReceiveMemoryWarningNotification] ) { - [self deleteAll]; + if ( _clearWhenMemoryLow ) + { + [self deleteAll]; + } } } diff --git a/BeeFramework/Core/Storage/Bee_CacheTest.m b/BeeFramework/Core/Storage/Bee_CacheTest.m new file mode 100644 index 0000000..384804e --- /dev/null +++ b/BeeFramework/Core/Storage/Bee_CacheTest.m @@ -0,0 +1,51 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_CacheTest.h +// + +#import "Bee.h" + +#if defined(__BEE_UNITTEST__) && __BEE_UNITTEST__ + +#pragma mark - + +TEST_CASE(BeeFileCache) +{ +} +TEST_CASE_END + +#pragma mark - + +TEST_CASE(BeeMemoryCache) +{ +} +TEST_CASE_END + +#endif // #if defined(__BEE_UNITTEST__) && __BEE_UNITTEST__ diff --git a/BeeFramework/Storage/Bee_Database.h b/BeeFramework/Core/Storage/Bee_Database.h similarity index 65% rename from BeeFramework/Storage/Bee_Database.h rename to BeeFramework/Core/Storage/Bee_Database.h index b1902a7..6b4219d 100644 --- a/BeeFramework/Storage/Bee_Database.h +++ b/BeeFramework/Core/Storage/Bee_Database.h @@ -37,32 +37,28 @@ #import "FMDatabase.h" -// obj1.to( obj2 ) -// .to( obj3 ) -// .to( obj4 ); - #pragma mark - @class BeeDatabase; -@interface NSObject(BeeDatabase) -@property (nonatomic, readonly) BeeDatabase * DB; -+ (BeeDatabase *)DB; -@end - -#pragma mark - - typedef BeeDatabase * (^BeeDatabaseBlockI)( NSInteger val ); typedef BeeDatabase * (^BeeDatabaseBlockU)( NSUInteger val ); typedef BeeDatabase * (^BeeDatabaseBlockN)( id key, ... ); +typedef BeeDatabase * (^BeeDatabaseBlockB)( BOOL flag ); typedef BeeDatabase * (^BeeDatabaseBlock)( void ); typedef NSArray * (^BeeDatabaseArrayBlock)( void ); +typedef id (^BeeDatabaseObjectBlock)( void ); +typedef id (^BeeDatabaseObjectBlockN)( id key, ... ); +typedef BOOL (^BeeDatabaseBoolBlock)( void ); #pragma mark - @interface BeeDatabase : NSObject { BOOL _autoOptimize; // TO BE DONE + BOOL _batch; + NSUInteger _identifier; + NSString * _filePath; FMDatabase * _database; @@ -88,15 +84,19 @@ typedef NSArray * (^BeeDatabaseArrayBlock)( void ); NSMutableArray * _field; NSMutableArray * _index; - NSMutableArray * _userInfo; + NSMutableArray * _classType; + NSMutableArray * _associate; + NSMutableArray * _has; } @property (nonatomic, assign) BOOL autoOptimize; // TO BE DONE @property (nonatomic, retain) NSString * filePath; @property (nonatomic, readonly) BOOL ready; +@property (nonatomic, readonly) NSUInteger identifier; @property (nonatomic, readonly) BeeDatabaseBlockN TABLE; @property (nonatomic, readonly) BeeDatabaseBlockN FIELD; +@property (nonatomic, readonly) BeeDatabaseBlockN FIELD_WITH_SIZE; @property (nonatomic, readonly) BeeDatabaseBlock UNSIGNED; @property (nonatomic, readonly) BeeDatabaseBlock NOT_NULL; @property (nonatomic, readonly) BeeDatabaseBlock PRIMARY_KEY; @@ -104,6 +104,7 @@ typedef NSArray * (^BeeDatabaseArrayBlock)( void ); @property (nonatomic, readonly) BeeDatabaseBlock DEFAULT_ZERO; @property (nonatomic, readonly) BeeDatabaseBlock DEFAULT_NULL; @property (nonatomic, readonly) BeeDatabaseBlockN DEFAULT; +@property (nonatomic, readonly) BeeDatabaseBlock UNIQUE; @property (nonatomic, readonly) BeeDatabaseBlock CREATE_IF_NOT_EXISTS; @property (nonatomic, readonly) BeeDatabaseBlockN INDEX_ON; @@ -159,6 +160,13 @@ typedef NSArray * (^BeeDatabaseArrayBlock)( void ); @property (nonatomic, readonly) BeeDatabaseBlock TRUNCATE; @property (nonatomic, readonly) BeeDatabaseBlock DELETE; +@property (nonatomic, readonly) BeeDatabaseBlock BATCH_BEGIN; +@property (nonatomic, readonly) BeeDatabaseBlock BATCH_END; + +@property (nonatomic, readonly) BeeDatabaseBlockN CLASS_TYPE; // for activeRecord +@property (nonatomic, readonly) BeeDatabaseBlockN ASSOCIATE; // for activeRecord +@property (nonatomic, readonly) BeeDatabaseBlockN HAS; // for activeRecord + @property (nonatomic, readonly) NSArray * resultArray; @property (nonatomic, readonly) NSUInteger resultCount; @property (nonatomic, readonly) NSInteger insertID; @@ -178,100 +186,18 @@ typedef NSArray * (^BeeDatabaseArrayBlock)( void ); - (void)close; - (void)clearState; -// create - -- (BeeDatabase *)table:(NSString *)name; -- (BeeDatabase *)field:(NSString *)name type:(NSString *)type size:(NSUInteger)size; -- (BeeDatabase *)unsignedType; -- (BeeDatabase *)notNull; -- (BeeDatabase *)primaryKey; -- (BeeDatabase *)autoIncrement; -- (BeeDatabase *)defaultZero; -- (BeeDatabase *)defaultNull; -- (BeeDatabase *)defaultValue:(id)value; -- (BOOL)createTableIfNotExists; -- (BOOL)createTableIfNotExists:(NSString *)table; -- (BOOL)indexTableOn:(NSArray *)fields; -- (BOOL)indexTable:(NSString *)table on:(NSArray *)fields; -- (BOOL)existsTable:(NSString *)table; - -// select - -- (BeeDatabase *)select:(NSString *)select; -- (BeeDatabase *)selectMax:(NSString *)select; -- (BeeDatabase *)selectMax:(NSString *)select alias:(NSString *)alias; -- (BeeDatabase *)selectMin:(NSString *)select; -- (BeeDatabase *)selectMin:(NSString *)select alias:(NSString *)alias; -- (BeeDatabase *)selectAvg:(NSString *)select; -- (BeeDatabase *)selectAvg:(NSString *)select alias:(NSString *)alias; -- (BeeDatabase *)selectSum:(NSString *)select; -- (BeeDatabase *)selectSum:(NSString *)select alias:(NSString *)alias; - -- (BeeDatabase *)distinct:(BOOL)flag; -- (BeeDatabase *)from:(NSString *)from; - -- (BeeDatabase *)where:(NSString *)key value:(id)value; -- (BeeDatabase *)orWhere:(NSString *)key value:(id)value; - -- (BeeDatabase *)whereIn:(NSString *)key values:(NSArray *)values; -- (BeeDatabase *)orWhereIn:(NSString *)key values:(NSArray *)values; -- (BeeDatabase *)whereNotIn:(NSString *)key values:(NSArray *)values; -- (BeeDatabase *)orWhereNotIn:(NSString *)key values:(NSArray *)values; ++ (NSString *)fieldNameForIdentifier:(NSString *)identifier; ++ (NSString *)tableNameForClass:(Class)clazz; -- (BeeDatabase *)like:(NSString *)field match:(id)value; -- (BeeDatabase *)notLike:(NSString *)field match:(id)value; -- (BeeDatabase *)orLike:(NSString *)field match:(id)value; -- (BeeDatabase *)orNotLike:(NSString *)field match:(id)value; +- (Class)classType; -- (BeeDatabase *)groupBy:(NSString *)by; +- (NSArray *)associateObjects; +- (NSArray *)associateObjectsFor:(Class)clazz; -- (BeeDatabase *)having:(NSString *)key value:(id)value; -- (BeeDatabase *)orHaving:(NSString *)key value:(id)value; - -- (BeeDatabase *)orderAscendBy:(NSString *)by; -- (BeeDatabase *)orderDescendBy:(NSString *)by; -- (BeeDatabase *)orderRandomBy:(NSString *)by; -- (BeeDatabase *)orderBy:(NSString *)by direction:(NSString *)direction; - -- (BeeDatabase *)limit:(NSUInteger)limit; -- (BeeDatabase *)offset:(NSUInteger)offset; - -- (BeeDatabase *)userInfo:(id)obj; - -// write - -- (BeeDatabase *)set:(NSString *)key; -- (BeeDatabase *)set:(NSString *)key value:(id)value; - -- (NSArray *)get; -- (NSArray *)get:(NSString *)table; -- (NSArray *)get:(NSString *)table limit:(NSUInteger)limit; -- (NSArray *)get:(NSString *)table limit:(NSUInteger)limit offset:(NSUInteger)offset; - -- (NSUInteger)count; -- (NSUInteger)count:(NSString *)table; - -- (NSInteger)insert; -- (NSInteger)insert:(NSString *)table; -- (NSInteger)insert:(NSString *)table set:(NSDictionary *)set; -- (NSInteger)insertSet:(NSDictionary *)set; - -- (BOOL)update; -- (BOOL)update:(NSString *)table; -- (BOOL)update:(NSString *)table set:(NSDictionary *)set; -- (BOOL)updateSet:(NSDictionary *)set; - -- (BOOL)empty; -- (BOOL)empty:(NSString *)table; - -- (BOOL)truncate; -- (BOOL)truncate:(NSString *)table; - -- (BOOL)delete; -- (BOOL)delete:(NSString *)table; +- (NSArray *)hasObjects; +- (NSArray *)hasObjectsFor:(Class)clazz; // internal user only - - (void)__internalResetCreate; - (void)__internalResetSelect; - (void)__internalResetWrite; diff --git a/BeeFramework/Storage/Bee_Database.m b/BeeFramework/Core/Storage/Bee_Database.m similarity index 77% rename from BeeFramework/Storage/Bee_Database.m rename to BeeFramework/Core/Storage/Bee_Database.m index 39da86e..a048a8c 100644 --- a/BeeFramework/Storage/Bee_Database.m +++ b/BeeFramework/Core/Storage/Bee_Database.m @@ -34,55 +34,126 @@ #import "Bee_Database.h" #import "Bee_Log.h" #import "Bee_Sandbox.h" +#import "Bee_ActiveRecord.h" +#import "Bee_ActiveBase.h" +#import "Bee_UnitTest.h" + #import "NSString+BeeExtension.h" #import "NSNumber+BeeExtension.h" #import "NSDictionary+BeeExtension.h" +#import "NSObject+BeeDatabase.h" #pragma mark - -static BeeDatabase * __sharedDB = nil; -static BeeDatabase * __mockedDB = nil; - -#pragma mark - - -@implementation NSObject(BeeDatabase) - -+ (BeeDatabase *)DB -{ - BeeDatabase * db = [BeeDatabase sharedDatabase]; - if ( nil == db ) - { - if ( nil == __mockedDB ) - { - __mockedDB = [[BeeDatabase alloc] init]; - } - - db = __mockedDB; - [db clearState]; - } - return db; -} - -- (BeeDatabase *)DB -{ - return [NSObject DB]; -} - -@end +@interface BeeDatabase(Private) -#pragma mark - ++ (NSString *)fieldNameForIdentifier:(NSString *)identifier; -@interface BeeDatabase(Private) - (void)initSelf; - (NSString *)internalCreateAliasFromTable:(NSString *)name; - (void)internalSelect:(NSString *)select alias:(NSString *)alias type:(NSString *)type; -- (void)internalWhere:(NSString *)key value:(NSString *)value type:(NSString *)type; -- (void)internalLike:(NSString *)field match:(NSString *)match type:(NSString *)type side:(NSString *)side not:(BOOL)not; -- (void)internalHaving:(NSString *)key value:(NSString *)value type:(NSString *)type; +- (void)internalWhere:(NSString *)key value:(NSObject *)value type:(NSString *)type; +- (void)internalLike:(NSString *)field match:(NSObject *)match type:(NSString *)type side:(NSString *)side not:(BOOL)not; +- (void)internalHaving:(NSString *)key value:(NSObject *)value type:(NSString *)type; - (NSString *)internalCompileSelect:(NSString *)override; - (NSString *)internalCompileCreate:(NSString *)table; - (NSString *)internalCompileIndex:(NSString *)table; + +// create + +- (BeeDatabase *)table:(NSString *)name; +- (BeeDatabase *)field:(NSString *)name type:(NSString *)type size:(NSUInteger)size; +- (BeeDatabase *)unsignedType; +- (BeeDatabase *)notNull; +- (BeeDatabase *)primaryKey; +- (BeeDatabase *)autoIncrement; +- (BeeDatabase *)defaultZero; +- (BeeDatabase *)defaultNull; +- (BeeDatabase *)defaultValue:(id)value; +- (BeeDatabase *)unique; +- (BOOL)createTableIfNotExists; +- (BOOL)createTableIfNotExists:(NSString *)table; +- (BOOL)indexTableOn:(NSArray *)fields; +- (BOOL)indexTable:(NSString *)table on:(NSArray *)fields; +- (BOOL)existsTable:(NSString *)table; + +// select + +- (BeeDatabase *)select:(NSString *)select; +- (BeeDatabase *)selectMax:(NSString *)select; +- (BeeDatabase *)selectMax:(NSString *)select alias:(NSString *)alias; +- (BeeDatabase *)selectMin:(NSString *)select; +- (BeeDatabase *)selectMin:(NSString *)select alias:(NSString *)alias; +- (BeeDatabase *)selectAvg:(NSString *)select; +- (BeeDatabase *)selectAvg:(NSString *)select alias:(NSString *)alias; +- (BeeDatabase *)selectSum:(NSString *)select; +- (BeeDatabase *)selectSum:(NSString *)select alias:(NSString *)alias; + +- (BeeDatabase *)distinct:(BOOL)flag; +- (BeeDatabase *)from:(NSString *)from; + +- (BeeDatabase *)where:(NSString *)key value:(id)value; +- (BeeDatabase *)orWhere:(NSString *)key value:(id)value; + +- (BeeDatabase *)whereIn:(NSString *)key values:(NSArray *)values; +- (BeeDatabase *)orWhereIn:(NSString *)key values:(NSArray *)values; +- (BeeDatabase *)whereNotIn:(NSString *)key values:(NSArray *)values; +- (BeeDatabase *)orWhereNotIn:(NSString *)key values:(NSArray *)values; + +- (BeeDatabase *)like:(NSString *)field match:(id)value; +- (BeeDatabase *)notLike:(NSString *)field match:(id)value; +- (BeeDatabase *)orLike:(NSString *)field match:(id)value; +- (BeeDatabase *)orNotLike:(NSString *)field match:(id)value; + +- (BeeDatabase *)groupBy:(NSString *)by; + +- (BeeDatabase *)having:(NSString *)key value:(id)value; +- (BeeDatabase *)orHaving:(NSString *)key value:(id)value; + +- (BeeDatabase *)orderAscendBy:(NSString *)by; +- (BeeDatabase *)orderDescendBy:(NSString *)by; +- (BeeDatabase *)orderRandomBy:(NSString *)by; +- (BeeDatabase *)orderBy:(NSString *)by direction:(NSString *)direction; + +- (BeeDatabase *)limit:(NSUInteger)limit; +- (BeeDatabase *)offset:(NSUInteger)offset; + +- (BeeDatabase *)classInfo:(id)obj; + +// write + +- (BeeDatabase *)set:(NSString *)key; +- (BeeDatabase *)set:(NSString *)key value:(id)value; + +- (NSArray *)get; +- (NSArray *)get:(NSString *)table; +- (NSArray *)get:(NSString *)table limit:(NSUInteger)limit; +- (NSArray *)get:(NSString *)table limit:(NSUInteger)limit offset:(NSUInteger)offset; + +- (NSUInteger)count; +- (NSUInteger)count:(NSString *)table; + +- (NSInteger)insert; +- (NSInteger)insert:(NSString *)table; + +- (BOOL)update; +- (BOOL)update:(NSString *)table; + +- (BOOL)empty; +- (BOOL)empty:(NSString *)table; + +- (BOOL)truncate; +- (BOOL)truncate:(NSString *)table; + +- (BOOL)delete; +- (BOOL)delete:(NSString *)table; + +// active record + +- (void)classType:(Class)clazz; +- (void)associate:(NSObject *)obj; + @end #pragma mark - @@ -91,10 +162,13 @@ @implementation BeeDatabase @dynamic autoOptimize; @dynamic ready; + @synthesize filePath = _filePath; +@synthesize identifier = _identifier; @dynamic TABLE; @dynamic FIELD; +@dynamic FIELD_WITH_SIZE; @dynamic UNSIGNED; @dynamic NOT_NULL; @dynamic PRIMARY_KEY; @@ -102,6 +176,7 @@ @implementation BeeDatabase @dynamic DEFAULT_ZERO; @dynamic DEFAULT_NULL; @dynamic DEFAULT; +@dynamic UNIQUE; @dynamic CREATE_IF_NOT_EXISTS; @dynamic INDEX_ON; @@ -156,10 +231,45 @@ @implementation BeeDatabase @dynamic TRUNCATE; @dynamic DELETE; -@synthesize resultArray = _resultArray; -@synthesize resultCount = _resultCount; -@synthesize insertID = _lastInsertID; -@synthesize succeed = _lastSucceed; +@dynamic BATCH_BEGIN; +@dynamic BATCH_END; + +@dynamic CLASS_TYPE; +@dynamic ASSOCIATE; + +@dynamic resultArray; +@dynamic resultCount; +@dynamic insertID; +@dynamic succeed; + +static BeeDatabase * __sharedDB = nil; +static NSUInteger __identSeed = 1; + +- (NSArray *)resultArray +{ + [self __internalResetSelect]; + [self __internalResetWrite]; + [self __internalResetCreate]; + +// [self __internalResetResult]; + + return [[[NSMutableArray alloc] initWithArray:_resultArray] autorelease]; +} + +- (NSUInteger)resultCount +{ + return _resultCount; +} + +- (NSInteger)insertID +{ + return _lastInsertID; +} + +- (BOOL)succeed +{ + return _lastSucceed; +} - (void)initSelf { @@ -175,7 +285,8 @@ - (void)initSelf _offset = 0; _orderby = [[NSMutableArray alloc] init]; _set = [[NSMutableDictionary alloc] init]; - _userInfo = [[NSMutableArray alloc] init];; + _classType = [[NSMutableArray alloc] init]; + _associate = [[NSMutableArray alloc] init]; _table = [[NSMutableArray alloc] init]; _field = [[NSMutableArray alloc] init]; @@ -183,10 +294,14 @@ - (void)initSelf _resultArray = [[NSMutableArray alloc] init]; _resultCount = 0; + + _identifier = __identSeed++; } + (BOOL)openSharedDatabase:(NSString *)path { + [self resetPrepareFlags]; + if ( __sharedDB ) { if ( __sharedDB.ready && [__sharedDB.filePath isEqualToString:path] ) @@ -197,7 +312,7 @@ + (BOOL)openSharedDatabase:(NSString *)path __sharedDB = nil; } - __sharedDB = [[BeeDatabase alloc] initWithPath:path]; + __sharedDB = [[[self class] alloc] initWithPath:path]; if ( __sharedDB ) { if ( NO == __sharedDB.ready ) @@ -218,14 +333,22 @@ + (BOOL)existsSharedDatabase:(NSString *)path + (void)closeSharedDatabase { [__sharedDB release]; - __sharedDB = nil; + __sharedDB = nil; + + [self resetPrepareFlags]; } + (void)setSharedDatabase:(BeeDatabase *)db { - [db retain]; - [__sharedDB release]; - __sharedDB = db; + if ( db != __sharedDB ) + { + [db retain]; + + [__sharedDB release]; + __sharedDB = db; + } + + [self resetPrepareFlags]; } + (BeeDatabase *)sharedDatabase @@ -283,6 +406,8 @@ - (BOOL)open:(NSString *)path [self close]; + CC( @"[DB] open '%@'", path ); + NSFileManager * manager = [NSFileManager defaultManager]; NSString * fullPath = [NSString stringWithFormat:@"%@/BeeDatabase/", [BeeSandbox docPath]]; @@ -323,6 +448,8 @@ - (void)close { if ( _database ) { + CC( @"[DB] open '%@'", _filePath ); + [_database close]; [_database release]; _database = nil; @@ -382,8 +509,11 @@ - (void)dealloc [_resultArray removeAllObjects]; [_resultArray release]; - [_userInfo removeAllObjects]; - [_userInfo release]; + [_classType removeAllObjects]; + [_classType release]; + + [_associate removeAllObjects]; + [_associate release]; [super dealloc]; } @@ -394,7 +524,8 @@ - (void)__internalResetCreate [_table removeAllObjects]; [_index removeAllObjects]; - [_userInfo removeAllObjects]; + [_classType removeAllObjects]; + [_associate removeAllObjects]; } - (BeeDatabase *)table:(NSString *)name @@ -404,13 +535,13 @@ - (BeeDatabase *)table:(NSString *)name if ( nil == name ) return self; - + for ( NSString * table in _table ) { - if ( [table isEqualToString:name] ) + if ( NSOrderedSame == [table compare:name options:NSCaseInsensitiveSearch] ) return self; } - + [_table addObject:name]; return self; } @@ -420,10 +551,12 @@ - (BeeDatabase *)field:(NSString *)name type:(NSString *)type size:(NSUInteger)s if ( nil == _database ) return self; + name = [[self class] fieldNameForIdentifier:name]; + for ( NSMutableDictionary * dict in _field ) { NSString * name2 = [dict objectForKey:@"name"]; - if ( [name2 isEqualToString:name] ) + if ( NSOrderedSame == [name2 compare:name options:NSCaseInsensitiveSearch] ) { if ( type ) { @@ -521,6 +654,19 @@ - (BeeDatabase *)defaultValue:(id)value return self; } +- (BeeDatabase *)unique +{ + if ( nil == _database ) + return self; + + NSMutableDictionary * dict = (NSMutableDictionary *)_field.lastObject; + if ( nil == dict ) + return self; + + [dict setObject:__INT(1) forKey:@"unique"]; + return self; +} + - (BOOL)createTableIfNotExists { return [self createTableIfNotExists:nil]; @@ -565,18 +711,21 @@ - (NSString *)internalCompileCreate:(NSString *)table [sql appendFormat:@"CREATE TABLE IF NOT EXISTS %@ ( ", table]; - for ( NSDictionary * dict in _field ) + for ( NSInteger i = 0; i < _field.count; ++i ) { + NSDictionary * dict = [_field objectAtIndex:i]; + NSString * name = (NSString *)[dict objectForKey:@"name"]; NSString * type = (NSString *)[dict objectForKey:@"type"]; - NSNumber * size = (NSNumber *)[dict objectForKey:@"name"]; + NSNumber * size = (NSNumber *)[dict objectForKey:@"size"]; NSNumber * PK = (NSNumber *)[dict objectForKey:@"primaryKey"]; NSNumber * AI = (NSNumber *)[dict objectForKey:@"autoIncrement"]; + NSNumber * UN = (NSNumber *)[dict objectForKey:@"unique"]; NSNumber * NN = (NSNumber *)[dict objectForKey:@"notNull"]; NSObject * defaultValue = [dict objectForKey:@"default"]; - if ( 0 == [_field indexOfObject:dict] ) + if ( 0 == i ) { [sql appendFormat:@"%@", name]; } @@ -605,6 +754,11 @@ - (NSString *)internalCompileCreate:(NSString *)table [sql appendString:@" AUTOINCREMENT"]; } + if ( UN && UN.intValue ) + { + [sql appendString:@" UNIQUE"]; + } + if ( NN && NN.intValue ) { [sql appendString:@" NOT NULL"]; @@ -612,18 +766,14 @@ - (NSString *)internalCompileCreate:(NSString *)table if ( defaultValue ) { - if ( [defaultValue isKindOfClass:[NSNumber class]] ) + if ( [defaultValue isKindOfClass:[NSNull class]] ) { - [sql appendFormat:@" DEFAULT '%@'", defaultValue]; + [sql appendString:@" DEFAULT NULL"]; } - else if ( [defaultValue isKindOfClass:[NSString class]] ) + else { [sql appendFormat:@" DEFAULT '%@'", defaultValue]; } - else if ( [defaultValue isKindOfClass:[NSNull class]] ) - { - [sql appendString:@" DEFAULT NULL"]; - } } } @@ -649,7 +799,12 @@ - (BOOL)indexTableOn:(NSArray *)fields if ( nil == table || 0 == table.length ) return NO; - [_index addObjectsFromArray:fields]; + for ( NSString * field in fields ) + { + field = [[self class] fieldNameForIdentifier:field]; + [_index addObject:field]; + } + if ( 0 == _index.count ) return NO; @@ -685,7 +840,12 @@ - (BOOL)indexTable:(NSString *)table on:(NSArray *)fields if ( nil == table || 0 == table.length ) return NO; - [_index addObjectsFromArray:fields]; + for ( NSString * field in fields ) + { + field = [[self class] fieldNameForIdentifier:field]; + [_index addObject:field]; + } + if ( 0 == _index.count ) return NO; @@ -707,9 +867,11 @@ - (NSString *)internalCompileIndex:(NSString *)table [sql appendFormat:@"CREATE INDEX IF NOT EXISTS index_%@ ON %@ ( ", table, table]; - for ( NSString * field in _index ) + for ( NSInteger i = 0; i < _index.count; ++i ) { - if ( 0 == [_index indexOfObject:field] ) + NSString * field = [_index objectAtIndex:i]; + + if ( 0 == i ) { [sql appendFormat:@"%@", field]; } @@ -755,7 +917,11 @@ - (void)__internalResetSelect [_having removeAllObjects]; [_orderby removeAllObjects]; - [_userInfo removeAllObjects]; + if ( NO == _batch ) + { + [_classType removeAllObjects]; + [_associate removeAllObjects]; + } _distinct = NO; _limit = 0; @@ -771,7 +937,11 @@ - (void)__internalResetWrite [_orderby removeAllObjects]; [_keys removeAllObjects]; - [_userInfo removeAllObjects]; + if ( NO == _batch ) + { + [_classType removeAllObjects]; + [_associate removeAllObjects]; + } _limit = 0; } @@ -902,7 +1072,7 @@ - (BeeDatabase *)from:(NSString *)from for ( NSString * table in _from ) { - if ( [table isEqualToString:from] ) + if ( NSOrderedSame == [table compare:from options:NSCaseInsensitiveSearch] ) return self; } @@ -910,20 +1080,29 @@ - (BeeDatabase *)from:(NSString *)from return self; } -- (void)internalWhere:(NSString *)key value:(NSString *)value type:(NSString *)type +- (void)internalWhere:(NSString *)key value:(NSObject *)value type:(NSString *)type { NSString * prefix = (0 == _where.count) ? @"" : type; NSString * sql = nil; + key = [[self class] fieldNameForIdentifier:key]; + if ( nil == value ) { sql = [NSString stringWithFormat:@"%@ %@ IS NULL", prefix, key]; } else { - sql = [NSString stringWithFormat:@"%@ %@ = '%@'", prefix, key, value]; + if ( [value isKindOfClass:[NSNumber class]] ) + { + sql = [NSString stringWithFormat:@"%@ %@ = %@", prefix, key, value]; + } + else + { + sql = [NSString stringWithFormat:@"%@ %@ = '%@'", prefix, key, value]; + } } - + [_where addObject:sql]; } @@ -986,13 +1165,15 @@ - (void)internalWhereIn:(NSString *)key values:(NSArray *)values not:(BOOL)not t if ( nil == key || nil == values || 0 == values.count ) return; + key = [[self class] fieldNameForIdentifier:key]; + NSMutableString * sql = [NSMutableString string]; if ( _where.count ) { [sql appendFormat:@"%@ ", type]; } - + [sql appendString:key]; if ( not ) @@ -1002,15 +1183,22 @@ - (void)internalWhereIn:(NSString *)key values:(NSArray *)values not:(BOOL)not t [sql appendString:@" IN ("]; - for ( NSObject * value in values ) + for ( NSInteger i = 0; i < values.count; ++i ) { - if ( 0 == [values indexOfObject:value] ) + NSObject * value = [values objectAtIndex:i]; + + if ( i > 0 ) + { + [sql appendFormat:@", "]; + } + + if ( [value isKindOfClass:[NSNumber class]] ) { [sql appendFormat:@"%@", value]; } else { - [sql appendFormat:@", %@", value]; + [sql appendFormat:@"'%@'", value]; } } @@ -1042,7 +1230,7 @@ - (BeeDatabase *)orLike:(NSString *)field match:(id)value if ( nil == _database ) return self; - [self internalLike:field match:value type:@"AND" side:@"both" not:NO]; + [self internalLike:field match:value type:@"OR" side:@"both" not:NO]; return self; } @@ -1051,15 +1239,17 @@ - (BeeDatabase *)orNotLike:(NSString *)field match:(id)value if ( nil == _database ) return self; - [self internalLike:field match:value type:@"AND" side:@"both" not:YES]; + [self internalLike:field match:value type:@"OR" side:@"both" not:YES]; return self; } -- (void)internalLike:(NSString *)field match:(NSString *)match type:(NSString *)type side:(NSString *)side not:(BOOL)not +- (void)internalLike:(NSString *)field match:(NSObject *)match type:(NSString *)type side:(NSString *)side not:(BOOL)not { if ( nil == field || nil == match ) return; + field = [[self class] fieldNameForIdentifier:field]; + NSString * value = nil; if ( [side isEqualToString:@"before"] ) @@ -1099,15 +1289,10 @@ - (BeeDatabase *)groupBy:(NSString *)by if ( nil == _database ) return self; - NSArray * array = [by componentsSeparatedByString:@","]; - for ( NSString * value in array ) - { - value = value.trim; - if ( value.length ) - { - [_groupby addObject:value]; - } - } + by = [[self class] fieldNameForIdentifier:by]; + + [_groupby addObject:by]; + return self; } @@ -1129,11 +1314,13 @@ - (BeeDatabase *)orHaving:(NSString *)key value:(id)value return self; } -- (void)internalHaving:(NSString *)key value:(NSString *)value type:(NSString *)type +- (void)internalHaving:(NSString *)key value:(NSObject *)value type:(NSString *)type { if ( nil == key || nil == value ) return; + key = [[self class] fieldNameForIdentifier:key]; + NSString * sql = nil; if ( _having.count ) @@ -1171,6 +1358,8 @@ - (BeeDatabase *)orderBy:(NSString *)by direction:(NSString *)direction if ( nil == by ) return self; + by = [[self class] fieldNameForIdentifier:by]; + NSString * sql = [NSString stringWithFormat:@"%@ %@", by, direction]; [_orderby addObject:sql]; @@ -1195,12 +1384,12 @@ - (BeeDatabase *)offset:(NSUInteger)offset return self; } -- (BeeDatabase *)userInfo:(id)obj +- (BeeDatabase *)classInfo:(id)obj { if ( nil == obj ) return self; - [_userInfo addObject:obj]; + [_classType addObject:obj]; return self; } @@ -1217,13 +1406,17 @@ - (BeeDatabase *)set:(NSString *)key value:(id)value if ( nil == key ) return self; - [_set setObject:(value ? value : [NSNull null]) forKey:key]; + key = [[self class] fieldNameForIdentifier:key]; + value = (value ? value : [NSNull null]); + + [_set setObject:value forKey:key]; return self; } - (void)__internalResetResult { [_resultArray removeAllObjects]; + _resultCount = 0; _lastInsertID = -1; _lastSucceed = NO; @@ -1305,9 +1498,11 @@ - (NSString *)internalCompileSelect:(NSString *)override if ( _select.count ) { - for ( NSString * select in _select ) + for ( NSInteger i = 0; i < _select.count; ++i ) { - if ( 0 == [_select indexOfObject:select] ) + NSString * select = [_select objectAtIndex:i]; + + if ( 0 == i ) { [sql appendString:select]; } @@ -1327,9 +1522,11 @@ - (NSString *)internalCompileSelect:(NSString *)override { [sql appendString:@" FROM "]; - for ( NSString * from in _from ) + for ( NSInteger i = 0; i < _from.count; ++i ) { - if ( 0 == [_from indexOfObject:from] ) + NSString * from = [_from objectAtIndex:i]; + + if ( 0 == i ) { [sql appendString:from]; } @@ -1370,9 +1567,11 @@ - (NSString *)internalCompileSelect:(NSString *)override { [sql appendString:@" GROUP BY "]; - for ( NSString * by in _groupby ) + for ( NSInteger i = 0; i < _groupby.count; ++i ) { - if ( 0 == [_groupby indexOfObject:by] ) + NSString * by = [_groupby objectAtIndex:i]; + + if ( 0 == i ) { [sql appendString:by]; } @@ -1397,9 +1596,11 @@ - (NSString *)internalCompileSelect:(NSString *)override { [sql appendString:@" ORDER BY "]; - for ( NSString * by in _orderby ) + for ( NSInteger i = 0; i < _orderby.count; ++i ) { - if ( 0 == [_orderby indexOfObject:by] ) + NSString * by = [_orderby objectAtIndex:i]; + + if ( 0 == i ) { [sql appendString:by]; } @@ -1414,11 +1615,11 @@ - (NSString *)internalCompileSelect:(NSString *)override { if ( _offset ) { - [sql appendFormat:@" LIMIT %lu, %lu", _offset, _limit]; + [sql appendFormat:@" LIMIT %u, %u", _offset, _limit]; } else { - [sql appendFormat:@" LIMIT %lu", _limit]; + [sql appendFormat:@" LIMIT %u", _limit]; } } @@ -1461,35 +1662,16 @@ - (NSUInteger)count:(NSString *)table - (NSInteger)insert { - return [self insert:nil set:nil]; + return [self insert:nil]; } - (NSInteger)insert:(NSString *)table -{ - return [self insert:table set:nil]; -} - -- (NSInteger)insertSet:(NSDictionary *)set -{ - return [self insert:nil set:set]; -} - -- (NSInteger)insert:(NSString *)table set:(NSDictionary *)set { [self __internalResetResult]; if ( nil == _database ) return -1; - if ( set ) - { - NSArray * allKeys = set.allKeys; - for ( NSString * key in allKeys ) - { - [self set:key value:[set objectForKey:key]]; - } - } - if ( 0 == _set.count ) return -1; @@ -1505,41 +1687,49 @@ - (NSInteger)insert:(NSString *)table set:(NSDictionary *)set NSArray * allKeys = _set.allKeys; NSMutableArray * allValues = [NSMutableArray array]; + NSString * field = nil; + NSObject * value = nil; + [sql appendFormat:@"INSERT INTO %@ (", table]; - for ( NSString * key in allKeys ) + for ( NSInteger i = 0; i < allKeys.count; ++i ) { - if ( 0 == [allKeys indexOfObject:key] ) + NSString * key = [allKeys objectAtIndex:i]; + + field = [[self class] fieldNameForIdentifier:key]; + value = [_set objectForKey:key]; + + if ( 0 == i ) { - [sql appendString:key]; + [sql appendString:field]; } else { - [sql appendFormat:@", %@", key]; + [sql appendFormat:@", %@", field]; } - - [allValues addObject:[_set objectForKey:key]]; + + [allValues addObject:value]; } [sql appendString:@") VALUES ("]; - for ( NSObject * obj in allValues ) + for ( NSInteger i = 0; i < allValues.count; ++i ) { - if ( 0 == [allValues indexOfObject:obj] ) + if ( 0 == i ) { - [sql appendFormat:@"'%@'", obj]; + [sql appendString:@"?"]; } else { - [sql appendFormat:@", '%@'", obj]; + [sql appendString:@", ?"]; } } - + [sql appendString:@")"]; [self __internalResetWrite]; - BOOL ret = [_database executeUpdate:sql]; + BOOL ret = [_database executeUpdate:sql withArgumentsInArray:allValues]; if ( ret ) { _lastInsertID = (NSInteger)_database.lastInsertRowId; @@ -1551,34 +1741,15 @@ - (NSInteger)insert:(NSString *)table set:(NSDictionary *)set - (BOOL)update { - return [self update:nil set:nil]; + return [self update:nil]; } - (BOOL)update:(NSString *)table -{ - return [self update:table set:nil]; -} - -- (BOOL)updateSet:(NSDictionary *)set -{ - return [self update:nil set:set]; -} - -- (BOOL)update:(NSString *)table set:(NSDictionary *)set { [self __internalResetResult]; if ( nil == _database ) return NO; - - if ( set ) - { - NSArray * allKeys = set.allKeys; - for ( NSString * key in allKeys ) - { - [self set:key value:[set objectForKey:key]]; - } - } if ( 0 == _set.count ) return NO; @@ -1593,18 +1764,32 @@ - (BOOL)update:(NSString *)table set:(NSDictionary *)set NSMutableString * sql = [NSMutableString string]; NSArray * allKeys = _set.allKeys; + NSMutableArray * allValues = [NSMutableArray array]; + + NSString * field = nil; + NSObject * value = nil; [sql appendFormat:@"UPDATE %@ SET ", table]; - for ( NSString * key in allKeys ) + for ( NSInteger i = 0; i < allKeys.count; ++i ) { - if ( 0 == [allKeys indexOfObject:key] ) - { - [sql appendFormat:@"%@ = '%@'", key, [_set objectForKey:key]]; - } - else + NSString * key = [allKeys objectAtIndex:i]; + + field = [[self class] fieldNameForIdentifier:key]; + value = [_set objectForKey:key]; + + if ( value ) { - [sql appendFormat:@", %@ = '%@'", key, [_set objectForKey:key]]; + [allValues addObject:value]; + + if ( 0 == i ) + { + [sql appendFormat:@"%@ = ?", field]; + } + else + { + [sql appendFormat:@", %@ = ?", field]; + } } } @@ -1622,9 +1807,11 @@ - (BOOL)update:(NSString *)table set:(NSDictionary *)set { [sql appendString:@" ORDER BY "]; - for ( NSString * by in _orderby ) + for ( NSInteger i = 0; i < _orderby.count; ++i ) { - if ( 0 == [_orderby indexOfObject:by] ) + NSString * by = [_orderby objectAtIndex:i]; + + if ( 0 == i ) { [sql appendString:by]; } @@ -1637,12 +1824,12 @@ - (BOOL)update:(NSString *)table set:(NSDictionary *)set if ( _limit ) { - [sql appendFormat:@" LIMIT %lu", _limit]; + [sql appendFormat:@" LIMIT %u", _limit]; } [self __internalResetWrite]; - BOOL ret = [_database executeUpdate:sql]; + BOOL ret = [_database executeUpdate:sql withArgumentsInArray:allValues]; if ( ret ) { _lastSucceed = YES; @@ -1775,7 +1962,7 @@ - (BOOL)delete:(NSString *)table if ( _limit ) { - [sql appendFormat:@" LIMIT %lu", _limit]; + [sql appendFormat:@" LIMIT %u", _limit]; } [self __internalResetWrite]; @@ -1790,6 +1977,90 @@ - (BOOL)delete:(NSString *)table return ret; } ++ (NSString *)fieldNameForIdentifier:(NSString *)identifier +{ + NSString * name = identifier.lowercaseString; + name = [name stringByReplacingOccurrencesOfString:@"." withString:@"_"]; + name = [name stringByReplacingOccurrencesOfString:@"/" withString:@"_"]; + return name; +} + ++ (NSString *)tableNameForClass:(Class)clazz +{ + return [NSString stringWithFormat:@"table_%@",[clazz description].lowercaseString]; +} + +- (Class)classType +{ + NSString * className = _classType.lastObject; + if ( nil == className || 0 == className.length ) + return NULL; + + Class classType = NSClassFromString( className ); + if ( nil == classType || NO == [classType conformsToProtocol:@protocol(BeeActiveProtocol)] ) + return NULL; + + return classType; +} + +- (NSArray *)associateObjects +{ + return _associate; +} + +- (NSArray *)associateObjectsFor:(Class)clazz +{ + NSMutableArray * array = [NSMutableArray array]; + + for ( NSObject * obj in _associate ) + { + if ( [obj isKindOfClass:clazz] ) + { + [array addObject:obj]; + } + } + + return array; +} + +- (NSArray *)hasObjects +{ + return _has; +} + +- (NSArray *)hasObjectsFor:(Class)clazz +{ + NSMutableArray * array = [NSMutableArray array]; + + for ( NSObject * obj in _has ) + { + if ( [obj isKindOfClass:clazz] ) + { + [array addObject:obj]; + } + } + + return array; +} + +- (void)classType:(Class)clazz +{ + if ( nil == clazz ) + return; + + [_classType addObject:[clazz description]]; + + [self from:[BeeDatabase tableNameForClass:clazz]]; +} + +- (void)associate:(NSObject *)obj +{ + if ( nil == obj ) + return; + + [_associate addObject:obj]; +} + - (BeeDatabaseBlockN)TABLE { BeeDatabaseBlockN block = ^ BeeDatabase * ( id first, ... ) @@ -1809,8 +2080,24 @@ - (BeeDatabaseBlockN)FIELD NSString * field = (NSString *)first; NSString * type = va_arg( args, NSString * ); - NSUInteger size = type ? va_arg( args, NSUInteger ) : 0; + return [self field:field type:type size:0]; + }; + + return [[block copy] autorelease]; +} + +- (BeeDatabaseBlockN)FIELD_WITH_SIZE +{ + BeeDatabaseBlockN block = ^ BeeDatabase * ( id first, ... ) + { + va_list args; + va_start( args, first ); + + NSString * field = (NSString *)first; + NSString * type = va_arg( args, NSString * ); + NSUInteger size = va_arg( args, NSUInteger ); + return [self field:field type:type size:size]; }; @@ -1887,6 +2174,16 @@ - (BeeDatabaseBlockN)DEFAULT return [[block copy] autorelease]; } +- (BeeDatabaseBlock)UNIQUE +{ + BeeDatabaseBlock block = ^ BeeDatabase * ( void ) + { + return [self unique]; + }; + + return [[block copy] autorelease]; +} + - (BeeDatabaseBlock)CREATE_IF_NOT_EXISTS { BeeDatabaseBlock block = ^ BeeDatabase * ( void ) @@ -2462,4 +2759,48 @@ - (BeeDatabaseBlock)DELETE return [[block copy] autorelease]; } +- (BeeDatabaseBlockN)CLASS_TYPE +{ + BeeDatabaseBlockN block = ^ BeeDatabase * ( id first, ... ) + { + [self classType:(Class)first]; + return self; + }; + + return [[block copy] autorelease]; +} + +- (BeeDatabaseBlockN)ASSOCIATE +{ + BeeDatabaseBlockN block = ^ BeeDatabase * ( id first, ... ) + { + [self associate:first]; + return self; + }; + + return [[block copy] autorelease]; +} + +- (BeeDatabaseBlock)BATCH_BEGIN +{ + BeeDatabaseBlock block = ^ BeeDatabase * ( void ) + { + _batch = YES; + return self; + }; + + return [[block copy] autorelease]; +} + +- (BeeDatabaseBlock)BATCH_END +{ + BeeDatabaseBlock block = ^ BeeDatabase * ( void ) + { + _batch = NO; + return self; + }; + + return [[block copy] autorelease]; +} + @end diff --git a/BeeFramework/Storage/Bee_DatabaseTest.m b/BeeFramework/Core/Storage/Bee_DatabaseTest.m similarity index 59% rename from BeeFramework/Storage/Bee_DatabaseTest.m rename to BeeFramework/Core/Storage/Bee_DatabaseTest.m index 595630b..799b33b 100644 --- a/BeeFramework/Storage/Bee_DatabaseTest.m +++ b/BeeFramework/Core/Storage/Bee_DatabaseTest.m @@ -30,135 +30,132 @@ // Bee_DatabaseTest.h // -#import "Bee_Log.h" -#import "Bee_Database.h" -#import "Bee_DatabaseTest.h" +#import "Bee.h" -#import "NSNumber+BeeExtension.h" +#if defined(__BEE_UNITTEST__) && __BEE_UNITTEST__ -#pragma mark - - -@implementation BeeDatabaseTest - -+ (void)run +TEST_CASE(BeeDatabase) { // 尝试在默认路径中打开数据库my.db if ( [BeeDatabase openSharedDatabase:@"my.db"] ) { // Create and table named 'blogs', consists of 4 fields, 'id'、'type'、'date'、'content' self.DB - .TABLE( @"blogs" ) - .FIELD( @"id", @"INTEGER", 12 ).PRIMARY_KEY().AUTO_INREMENT() - .FIELD( @"type", @"TEXT", 20 ) - .FIELD( @"date", @"TEXT", 64 ) - .FIELD( @"content", @"TEXT", 140 ) - .CREATE_IF_NOT_EXISTS(); - NSAssert( self.DB.succeed, nil ); + .TABLE( @"blogs" ) + .FIELD( @"id", @"INTEGER" ).PRIMARY_KEY().AUTO_INREMENT() + .FIELD( @"type", @"TEXT" ) + .FIELD( @"date", @"TEXT" ) + .FIELD( @"content", @"TEXT" ) + .CREATE_IF_NOT_EXISTS(); + NSAssert( self.DB.succeed, nil ); // Create an index on 'blogs.id' self.DB - .TABLE( @"blogs" ) - .INDEX_ON( @"id", nil ); - NSAssert( self.DB.succeed, nil ); + .TABLE( @"blogs" ) + .INDEX_ON( @"id", nil ); + NSAssert( self.DB.succeed, nil ); // Clear 'blogs' self.DB - .FROM( @"blogs" ) - .EMPTY(); - NSAssert( self.DB.succeed, nil ); + .FROM( @"blogs" ) + .EMPTY(); + NSAssert( self.DB.succeed, nil ); // Try to insert 1 row self.DB - .FROM( @"blogs" ) - .SET( @"type", @"Test" ) - .SET( @"date", [[NSDate date] description] ) - .SET( @"content", @"Hello, world!" ) - .INSERT(); // write once - NSAssert( self.DB.succeed, nil ); + .FROM( @"blogs" ) + .SET( @"type", @"Test" ) + .SET( @"date", [[NSDate date] description] ) + .SET( @"content", @"Hello, world!" ) + .INSERT(); // write once + NSAssert( self.DB.succeed, nil ); // Try to delete 1 row self.DB - .FROM( @"blogs" ) - .WHERE( @"id", __INT(self.DB.insertID) ) - .DELETE(); - NSAssert( self.DB.succeed, nil ); - + .FROM( @"blogs" ) + .WHERE( @"id", __INT(self.DB.insertID) ) + .DELETE(); + NSAssert( self.DB.succeed, nil ); + // Count all self.DB - .FROM( @"blogs" ) - .COUNT(); - NSAssert( self.DB.succeed, nil ); - NSAssert( self.DB.resultCount == 0, nil ); - + .FROM( @"blogs" ) + .COUNT(); + NSAssert( self.DB.succeed, nil ); + NSAssert( self.DB.resultCount == 0, nil ); + // Try to insert 30 rows with different 'type's for ( NSUInteger i = 0; i < 30; ++i ) { self.DB - .FROM( @"blogs" ) - .SET( @"date", [[NSDate date] description] ) - .SET( @"content", [NSString stringWithFormat:@"Some content %lu", i] ); + .FROM( @"blogs" ) + .SET( @"date", [[NSDate date] description] ) + .SET( @"content", [NSString stringWithFormat:@"Some content %u", i] ); if ( 0 == (i % 3) ) { self.DB - .SET( @"type", @"ObjC" ); + .SET( @"type", @"ObjC" ); } else if ( 1 == (i % 3) ) { self.DB - .SET( @"type", @"MacOS" ); + .SET( @"type", @"MacOS" ); } else if ( 2 == (i % 3) ) { self.DB - .SET( @"type", @"iOS" ); + .SET( @"type", @"iOS" ); } - + // Insert self.DB - .INSERT(); // write once - NSAssert( self.DB.succeed, nil ); - NSAssert( self.DB.insertID > 0, nil ); - + .INSERT(); // write once + NSAssert( self.DB.succeed, nil ); + NSAssert( self.DB.insertID > 0, nil ); + // Update 'content' with new 'id' self.DB - .FROM( @"blogs" ) - .WHERE( @"id", __INT(self.DB.insertID) ) - .SET( @"content", [NSString stringWithFormat:@"Some content %lu", self.DB.insertID] ) - .UPDATE(); - NSAssert( self.DB.succeed, nil ); + .FROM( @"blogs" ) + .WHERE( @"id", __INT(self.DB.insertID) ) + .SET( @"content", [NSString stringWithFormat:@"Some content %u", self.DB.insertID] ) + .UPDATE(); + NSAssert( self.DB.succeed, nil ); } // Count all self.DB - .FROM( @"blogs" ) - .COUNT(); - NSAssert( self.DB.succeed, nil ); - NSAssert( self.DB.resultCount == 30, nil ); + .FROM( @"blogs" ) + .COUNT(); + NSAssert( self.DB.succeed, nil ); + NSAssert( self.DB.resultCount == 30, nil ); // Count how many rows' 'type' is 'ObjC' there self.DB - .FROM( @"blogs" ) - .WHERE( @"type", @"ObjC" ) - .COUNT(); - NSAssert( self.DB.succeed, nil ); - NSAssert( self.DB.resultCount == 10, nil ); - + .FROM( @"blogs" ) + .WHERE( @"type", @"ObjC" ) + .COUNT(); + NSAssert( self.DB.succeed, nil ); + NSAssert( self.DB.resultCount == 10, nil ); + // Query all rows by 3 pages for ( NSUInteger i = 0; i < 3; ++i ) { self.DB - .FROM( @"blogs" ) - .OFFSET( 10 * i ) - .LIMIT( 10 ) - .GET(); - NSAssert( self.DB.succeed, nil ); - NSAssert( self.DB.resultCount > 0, nil ); - NSAssert( self.DB.resultCount == self.DB.resultArray.count, nil ); + .FROM( @"blogs" ) + .OFFSET( 10 * i ) + .LIMIT( 10 ) + .GET(); + NSAssert( self.DB.succeed, nil ); + NSAssert( self.DB.resultCount > 0, nil ); + NSAssert( self.DB.resultCount == self.DB.resultArray.count, nil ); VAR_DUMP( self.DB.resultArray ); } + + [BeeDatabase closeSharedDatabase]; } } +TEST_CASE_END -@end +#endif // #if defined(__BEE_UNITTEST__) && __BEE_UNITTEST__ diff --git a/BeeFramework/Foundation/Bee_Keychain.h b/BeeFramework/Core/Storage/Bee_Keychain.h similarity index 90% rename from BeeFramework/Foundation/Bee_Keychain.h rename to BeeFramework/Core/Storage/Bee_Keychain.h index 9d7f1fd..fd7bf46 100644 --- a/BeeFramework/Foundation/Bee_Keychain.h +++ b/BeeFramework/Core/Storage/Bee_Keychain.h @@ -39,16 +39,6 @@ #pragma mark - -@interface NSObject(BeeKeychain) - -- (NSString *)readValueForKey:(NSString *)key; -- (void)writeValue:(NSString *)value forKey:(NSString *)key; -- (void)deleteValueForKey:(NSString *)key; - -@end - -#pragma mark - - @interface BeeKeychain : NSObject + (void)setDefaultDomain:(NSString *)domain; diff --git a/BeeFramework/Foundation/Bee_Keychain.m b/BeeFramework/Core/Storage/Bee_Keychain.m similarity index 92% rename from BeeFramework/Foundation/Bee_Keychain.m rename to BeeFramework/Core/Storage/Bee_Keychain.m index 6721ee4..cc2bbc1 100644 --- a/BeeFramework/Foundation/Bee_Keychain.m +++ b/BeeFramework/Core/Storage/Bee_Keychain.m @@ -35,27 +35,6 @@ #pragma mark - -@implementation NSObject(BeeKeychain) - -- (NSString *)readValueForKey:(NSString *)key -{ - return [BeeKeychain readValueForKey:key andDomain:[[self class] description]]; -} - -- (void)writeValue:(NSString *)value forKey:(NSString *)key -{ - [BeeKeychain writeValue:value forKey:key andDomain:[[self class] description]]; -} - -- (void)deleteValueForKey:(NSString *)key -{ - [BeeKeychain deleteValueForKey:key andDomain:[[self class] description]]; -} - -@end - -#pragma mark - - #undef DEFAULT_DOMAIN #define DEFAULT_DOMAIN @"BeeKeychain" diff --git a/BeeFramework/Core/Storage/Bee_KeychainTest.m b/BeeFramework/Core/Storage/Bee_KeychainTest.m new file mode 100644 index 0000000..a94773c --- /dev/null +++ b/BeeFramework/Core/Storage/Bee_KeychainTest.m @@ -0,0 +1,45 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_KeychainTest.h +// + +#import "Bee.h" + +#if defined(__BEE_UNITTEST__) && __BEE_UNITTEST__ + +#pragma mark - + +TEST_CASE(BeeKeychain) +{ +} +TEST_CASE_END + + +#endif // #if defined(__BEE_UNITTEST__) && __BEE_UNITTEST__ diff --git a/BeeFramework/Storage/Bee_ActiveRecordTest.h b/BeeFramework/Core/Storage/Bee_Storage.h similarity index 89% rename from BeeFramework/Storage/Bee_ActiveRecordTest.h rename to BeeFramework/Core/Storage/Bee_Storage.h index e927963..93c2bfc 100644 --- a/BeeFramework/Storage/Bee_ActiveRecordTest.h +++ b/BeeFramework/Core/Storage/Bee_Storage.h @@ -27,15 +27,13 @@ // IN THE SOFTWARE. // // -// Bee_ActiveRecordTest.h +// Bee_Storage.h // -#import "Bee_Precompile.h" -#import "Bee_Database.h" +#import "Bee_ActiveBase.h" #import "Bee_ActiveRecord.h" - -#pragma mark - - -@interface BeeActiveRecordTest : NSObject -+ (void)run; -@end +#import "Bee_Cache.h" +#import "Bee_Database.h" +#import "Bee_Keychain.h" +#import "NSObject+BeeDatabase.h" +#import "NSObject+BeeKeychain.h" diff --git a/BeeFramework/Core/Storage/Bee_Storage.m b/BeeFramework/Core/Storage/Bee_Storage.m new file mode 100644 index 0000000..af3591b --- /dev/null +++ b/BeeFramework/Core/Storage/Bee_Storage.m @@ -0,0 +1,33 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_Storage.h +// + +#import "Bee_Storage.h" diff --git a/BeeFramework/MVC/View/UIView+BeeBackground.h b/BeeFramework/Core/Storage/Extension/NSObject+BeeDatabase.h similarity index 84% rename from BeeFramework/MVC/View/UIView+BeeBackground.h rename to BeeFramework/Core/Storage/Extension/NSObject+BeeDatabase.h index ba11a29..e8c4e63 100644 --- a/BeeFramework/MVC/View/UIView+BeeBackground.h +++ b/BeeFramework/Core/Storage/Extension/NSObject+BeeDatabase.h @@ -27,20 +27,21 @@ // IN THE SOFTWARE. // // -// UIView+BeeBackground.h +// NSObject+BeeDatabase.h // #import "Bee_Precompile.h" -#import "Bee_UISignal.h" -#import "Bee_UIImageView.h" +#import "Bee_Database.h" #pragma mark - -@interface UIView(BeeBackground) +@interface NSObject(BeeDatabase) -@property (nonatomic, readonly) BeeUIImageView * backgroundImageView; +@property (nonatomic, readonly) BeeDatabase * DB; -- (void)setBackgroundImage:(UIImage *)image; -- (void)fitBackgroundFrame; ++ (BeeDatabase *)DB; + +- (NSString *)tableName; ++ (NSString *)tableName; @end diff --git a/BeeFramework/Core/Storage/Extension/NSObject+BeeDatabase.m b/BeeFramework/Core/Storage/Extension/NSObject+BeeDatabase.m new file mode 100644 index 0000000..2de4f25 --- /dev/null +++ b/BeeFramework/Core/Storage/Extension/NSObject+BeeDatabase.m @@ -0,0 +1,81 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// NSObject+BeeDatabase.h +// + +#import "Bee_Precompile.h" +#import "Bee_Database.h" +#import "NSObject+BeeDatabase.h" + +#pragma mark - + +@implementation NSObject(BeeDatabase) + ++ (BeeDatabase *)DB +{ + BeeDatabase * db = [BeeDatabase sharedDatabase]; + if ( nil == db ) + { + NSBundle * bundle = [NSBundle mainBundle]; + NSString * bundleName = [bundle objectForInfoDictionaryKey:@"CFBundleName"]; + if ( bundleName ) + { + NSString * dbName = [NSString stringWithFormat:@"%@.db", bundleName]; + BOOL succeed = [BeeDatabase openSharedDatabase:dbName]; + if ( succeed ) + { + db = [BeeDatabase sharedDatabase]; + } + } + + if ( db ) + { + [db clearState]; + } + } + return db; +} + +- (BeeDatabase *)DB +{ + return [NSObject DB]; +} + +- (NSString *)tableName +{ + return [[self class] tableName]; +} + ++ (NSString *)tableName +{ + return [BeeDatabase tableNameForClass:self]; +} + +@end diff --git a/BeeFramework/Core/Storage/Extension/NSObject+BeeKeychain.h b/BeeFramework/Core/Storage/Extension/NSObject+BeeKeychain.h new file mode 100644 index 0000000..3fa46a4 --- /dev/null +++ b/BeeFramework/Core/Storage/Extension/NSObject+BeeKeychain.h @@ -0,0 +1,44 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// NSObject+BeeKeychain.h +// + +#import "Bee_Precompile.h" +#import "Bee_Keychain.h" + +#pragma mark - + +@interface NSObject(BeeKeychain) + +- (NSString *)keychainRead:(NSString *)key; +- (void)keychainWrite:(NSString *)value forKey:(NSString *)key; +- (void)keychainDelete:(NSString *)key; + +@end diff --git a/BeeFramework/Core/Storage/Extension/NSObject+BeeKeychain.m b/BeeFramework/Core/Storage/Extension/NSObject+BeeKeychain.m new file mode 100644 index 0000000..63eec95 --- /dev/null +++ b/BeeFramework/Core/Storage/Extension/NSObject+BeeKeychain.m @@ -0,0 +1,57 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// NSObject+BeeKeychain.h +// + +#import "Bee_Precompile.h" +#import "Bee_Keychain.h" +#import "NSObject+BeeKeychain.h" + +#pragma mark - + +@implementation NSObject(BeeKeychain) + +- (NSString *)keychainRead:(NSString *)key +{ + return [BeeKeychain readValueForKey:key andDomain:[[self class] description]]; +} + +- (void)keychainWrite:(NSString *)value forKey:(NSString *)key +{ + [BeeKeychain writeValue:value forKey:key andDomain:[[self class] description]]; +} + +- (void)keychainDelete:(NSString *)key +{ + [BeeKeychain deleteValueForKey:key andDomain:[[self class] description]]; +} + +@end + diff --git a/BeeFramework/Core/UnitTest/Bee_UnitTest.h b/BeeFramework/Core/UnitTest/Bee_UnitTest.h new file mode 100644 index 0000000..24581ff --- /dev/null +++ b/BeeFramework/Core/UnitTest/Bee_UnitTest.h @@ -0,0 +1,71 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_UnitTest.h +// + +#import "Bee_Precompile.h" +#import "Bee_Database.h" +#include + +#undef TEST_CASE +#define TEST_CASE( __name ) \ + @interface TestCase##__name : BeeTestCase \ + @end \ + @implementation TestCase##__name \ + + (BOOL)runTests { \ + BOOL __testCasePassed = NO; \ + @try { + +#undef TEST_CASE_END +#define TEST_CASE_END \ + } \ + @catch ( NSException * e ) { \ + __testCasePassed = NO; \ + } \ + @finally { \ + __testCasePassed = YES; \ + } \ + return __testCasePassed; \ + } \ + @end + +#pragma mark - + +@interface BeeTestCase : NSObject ++ (BOOL)runTests; +@end + +#pragma mark - + +@interface BeeUnitTest : NSObject ++ (NSUInteger)failedCount; ++ (NSUInteger)succeedCount; ++ (BOOL)runTests; +@end diff --git a/BeeFramework/Core/UnitTest/Bee_UnitTest.m b/BeeFramework/Core/UnitTest/Bee_UnitTest.m new file mode 100644 index 0000000..353f44d --- /dev/null +++ b/BeeFramework/Core/UnitTest/Bee_UnitTest.m @@ -0,0 +1,149 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_ActiveBase.h +// + +#import "Bee_Precompile.h" +#import "Bee_Log.h" +#import "Bee_Runtime.h" +#import "Bee_Database.h" +#import "Bee_UnitTest.h" + +#import "NSObject+BeeTypeConversion.h" +#import "NSDictionary+BeeExtension.h" +#import "NSNumber+BeeExtension.h" + +#include + +#pragma mark - + +@implementation BeeTestCase + ++ (BOOL)runTests +{ + return YES; +} + +@end + +#pragma mark - + +@implementation BeeUnitTest + +static NSUInteger __failedCount = 0; +static NSUInteger __succeedCount = 0; + ++ (NSUInteger)failedCount +{ + return __failedCount; +} + ++ (NSUInteger)succeedCount +{ + return __succeedCount; +} + ++ (BOOL)runTests +{ +#if defined(__BEE_UNITTEST__) && __BEE_UNITTEST__ + + __failedCount = 0; + __succeedCount = 0; + + NSUInteger classesCount = 0; + Class * classes = objc_copyClassList( &classesCount ); + + NSMutableArray * availableCases = [NSMutableArray array]; + + for ( unsigned int i = 0; i < classesCount; ++i ) + { + Class classType = classes[i]; + if ( classType == [BeeTestCase class] ) + continue; + +// const char * imageName = class_getImageName( classType ); +// CC( @"image = %s", imageName ); + + if ( NO == class_respondsToSelector( classType, @selector(doesNotRecognizeSelector:) ) ) + continue; + if ( NO == class_respondsToSelector( classType, @selector(methodSignatureForSelector:) ) ) + continue; + + if ( [classType isSubclassOfClass:[BeeTestCase class]] ) + { + NSString * className = [NSString stringWithUTF8String:class_getName(classType)]; + [availableCases addObject:className]; + } + } + + CC( @"=====================================" ); + CC( @"Total %d cases", availableCases.count ); + CC( @"=====================================" ); + + if ( availableCases.count ) + { + [availableCases sortUsingComparator:^NSComparisonResult(id obj1, id obj2) { + return [obj1 compare:obj2 options:NSCaseInsensitiveSearch]; + }]; + + for ( NSString * className in availableCases ) + { + CC( @"Testing '%@' ...", className ); + + Class clazz = NSClassFromString( className ); + if ( clazz ) + { + BOOL ret = [clazz runTests]; + if ( ret ) + { + __succeedCount += 1; + } + else + { + __failedCount += 1; + } + } + } + } + + CC( @"=====================================" ); + CC( @"succeed(%d), failed(%d)", __succeedCount, __failedCount ); + CC( @"=====================================" ); + + return __failedCount ? NO : YES; + +#else // #if defined(__BEE_UNITTEST__) && __BEE_UNITTEST__ + + return YES; + +#endif // #if defined(__BEE_UNITTEST__) && __BEE_UNITTEST__ +} + +@end diff --git a/BeeFramework/Foundation/Bee_Network.m b/BeeFramework/Foundation/Bee_Network.m deleted file mode 100644 index 515d61c..0000000 --- a/BeeFramework/Foundation/Bee_Network.m +++ /dev/null @@ -1,1426 +0,0 @@ -// -// ______ ______ ______ -// /\ __ \ /\ ___\ /\ ___\ -// \ \ __< \ \ __\_ \ \ __\_ -// \ \_____\ \ \_____\ \ \_____\ -// \/_____/ \/_____/ \/_____/ -// -// Copyright (c) 2012 BEE creators -// http://www.whatsbug.com -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -// IN THE SOFTWARE. -// -// -// Bee_Network.m -// - -#include - -#import "Bee_Precompile.h" -#import "Bee_Network.h" -#import "Bee_Runtime.h" -#import "Bee_Log.h" - -#import "NSArray+BeeExtension.h" -#import "NSDictionary+BeeExtension.h" - -#import "ASIHTTPRequest.h" -#import "ASIDataDecompressor.h" -#import "ASIFormDataRequest.h" - -#pragma mark - - -#undef DEFAULT_BLACKLIST_TIMEOUT -#define DEFAULT_BLACKLIST_TIMEOUT (60.0f * 5.0f) // 黑名单超时 - -#undef DEFAULT_GET_TIMEOUT -#define DEFAULT_GET_TIMEOUT (30.0f) // 取图30秒超时 - -#undef DEFAULT_POST_TIMEOUT -#define DEFAULT_POST_TIMEOUT (30.0f) // 发协议30秒超时 - -#undef DEFAULT_UPLOAD_TIMEOUT -#define DEFAULT_UPLOAD_TIMEOUT (120.0f) // 上传图片120秒超时 - -#pragma mark - - -@implementation NSObject(BeeRequestResponder) - -- (BOOL)isRequestResponder -{ - if ( [self respondsToSelector:@selector(handleRequest:)] ) - { - return YES; - } - - return NO; -} - -- (BeeRequest *)GET:(NSString *)url -{ - if ( [self isRequestResponder] ) - { - BeeRequest * request = [BeeRequestQueue GET:url]; - [request addResponder:self]; -// request.responder = self; - return request; - } - else - { - return nil; - } -} - -- (BeeRequest *)POST:(NSString *)url text:(NSString *)text -{ - if ( [self isRequestResponder] ) - { - NSData * data = [text dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]; - BeeRequest * request = [BeeRequestQueue POST:url data:data]; - [request addResponder:self]; -// request.responder = self; - return request; - } - else - { - return nil; - } -} - -- (BeeRequest *)POST:(NSString *)url data:(NSData *)data -{ - if ( [self isRequestResponder] ) - { - BeeRequest * request = [BeeRequestQueue POST:url data:data]; - [request addResponder:self]; -// request.responder = self; - return request; - } - else - { - return nil; - } -} - -- (BeeRequest *)POST:(NSString *)url dict:(NSDictionary *)kvs -{ - if ( [self isRequestResponder] ) - { - BeeRequest * request = [BeeRequestQueue POST:url params:kvs]; - [request addResponder:self]; -// request.responder = self; - return request; - } - else - { - return nil; - } -} - -- (BeeRequest *)POST:(NSString *)url params:(id)first, ... -{ - NSMutableDictionary * dict = [NSMutableDictionary dictionary]; - - va_list args; - va_start( args, first ); - - for ( ;; ) - { - NSObject * key = [dict count] ? va_arg( args, NSObject * ) : first; - if ( nil == key ) - break; - - NSObject * value = va_arg( args, NSObject * ); - if ( nil == value ) - break; - - CC( @"POST, %@ = %@", [key description], [value description] ); - - [dict setObject:value forKey:key]; - } - - if ( [self isRequestResponder] ) - { - BeeRequest * request = [BeeRequestQueue POST:url params:dict]; - [request addResponder:self]; -// request.responder = self; - return request; - } - else - { - return nil; - } -} - -- (BeeRequest *)POST:(NSString *)url files:(NSDictionary *)files -{ - if ( [self isRequestResponder] ) - { - BeeRequest * request = [BeeRequestQueue POST:url files:files]; - [request addResponder:self]; -// request.responder = self; - return request; - } - else - { - return nil; - } -} - -- (BeeRequest *)POST:(NSString *)url files:(NSDictionary *)files dict:(NSDictionary *)kvs -{ - if ( [self isRequestResponder] ) - { - BeeRequest * request = [BeeRequestQueue POST:url files:files params:kvs]; - [request addResponder:self]; -// request.responder = self; - return request; - } - else - { - return nil; - } -} - -- (BeeRequest *)POST:(NSString *)url files:(NSDictionary *)files params:(id)first, ... -{ - NSMutableDictionary * dict = [NSMutableDictionary dictionary]; - - va_list args; - va_start( args, first ); - - for ( ;; ) - { - NSObject * key = [dict count] ? va_arg( args, NSObject * ) : first; - if ( nil == key ) - break; - - NSObject * value = va_arg( args, NSObject * ); - if ( nil == value ) - break; - - [dict setObject:value forKey:key]; - } - - if ( [self isRequestResponder] ) - { - BeeRequest * request = [BeeRequestQueue POST:url files:files params:dict]; - [request addResponder:self]; -// request.responder = self; - return request; - } - else - { - return nil; - } -} - -- (BOOL)requestingURL -{ - if ( [self isRequestResponder] ) - { - return [BeeRequestQueue requesting:nil byResponder:self]; - } - else - { - return NO; - } -} - -- (BOOL)requestingURL:(NSString *)url -{ - if ( [self isRequestResponder] ) - { - return [BeeRequestQueue requesting:url byResponder:self]; - } - else - { - return NO; - } -} - -- (NSArray *)requests -{ - return [BeeRequestQueue requests:nil byResponder:self]; -} - -- (NSArray *)requests:(NSString *)url -{ - return [BeeRequestQueue requests:url byResponder:self]; -} - -- (void)cancelRequests -{ - if ( [self isRequestResponder] ) - { - [BeeRequestQueue cancelRequestByResponder:self]; - } -} - -- (void)handleRequest:(BeeRequest *)request -{ -} - -@end - -#pragma mark - - -@interface BeeRequest(Private) -- (void)updateSendProgress; -- (void)updateRecvProgress; -@end - -@implementation BeeRequest - -DEF_INT( STATE_CREATED, 0 ); -DEF_INT( STATE_SENDING, 1 ); -DEF_INT( STATE_RECVING, 2 ); -DEF_INT( STATE_FAILED, 3 ); -DEF_INT( STATE_SUCCEED, 4 ); -DEF_INT( STATE_CANCELLED, 5 ); - -@synthesize state = _state; -@synthesize errorCode = _errorCode; -//@synthesize responder = _responder; -@synthesize responders = _responders; -@synthesize userInfo = _userInfo; - -@synthesize whenUpdate = _whenUpdate; - -@synthesize initTimeStamp = _initTimeStamp; -@synthesize sendTimeStamp = _sendTimeStamp; -@synthesize recvTimeStamp = _recvTimeStamp; -@synthesize doneTimeStamp = _doneTimeStamp; - -@synthesize timeCostPending; // 排队等待耗时 -@synthesize timeCostOverDNS; // 网络连接耗时(DNS) -@synthesize timeCostRecving; // 网络收包耗时 -@synthesize timeCostOverAir; // 网络整体耗时 - -#if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ -@synthesize callstack = _callstack; -#endif // #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ - -@synthesize created; -@synthesize sending; -@synthesize recving; -@synthesize failed; -@synthesize succeed; -//@synthesize cancelled; -@synthesize sendProgressed = _sendProgressed; -@synthesize recvProgressed = _recvProgressed; - -@synthesize uploadPercent; -@synthesize uploadBytes; -@synthesize uploadTotalBytes; -@synthesize downloadPercent; -@synthesize downloadBytes; -@synthesize downloadTotalBytes; - -- (id)initWithURL:(NSURL *)newURL -{ - self = [super initWithURL:newURL]; - if ( self ) - { - _state = BeeRequest.STATE_CREATED; - _errorCode = 0; - - _responders = [[NSMutableArray alloc] init]; - _userInfo = [[NSMutableDictionary alloc] init]; - - _whenUpdate = nil; - - _sendProgressed = NO; - _recvProgressed = NO; - - _initTimeStamp = [NSDate timeIntervalSinceReferenceDate]; - _sendTimeStamp = _initTimeStamp; - _recvTimeStamp = _initTimeStamp; - _doneTimeStamp = _initTimeStamp; - - #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ - _callstack = [[NSMutableArray alloc] init]; - [_callstack addObjectsFromArray:[BeeRuntime callstack:16]]; - #endif // #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ - } - - return self; -} - -- (NSString *)description -{ - return [NSString stringWithFormat:@"%@ %@, state ==> %d, %d/%d", - self.requestMethod, [self.url absoluteString], - self.state, - [self uploadBytes], [self downloadBytes]]; -} - -- (void)dealloc -{ - self.whenUpdate = nil; - - [_responders removeAllObjectsNoRelease]; - [_responders release]; - - [_userInfo removeAllObjects]; - [_userInfo release]; - -#if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ - [_callstack removeAllObjects]; - [_callstack release]; -#endif // #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ - - [super dealloc]; -} - -- (CGFloat)uploadPercent -{ - NSUInteger bytes1 = self.uploadBytes; - NSUInteger bytes2 = self.uploadTotalBytes; - - return bytes2 ? ((CGFloat)bytes1 / (CGFloat)bytes2) : 0.0f; -} - -- (NSUInteger)uploadBytes -{ - if ( [self.requestMethod isEqualToString:@"GET"] ) - { - return 0; - } - else if ( [self.requestMethod isEqualToString:@"POST"] ) - { - return self.postLength; - } - - return 0; -} - -- (NSUInteger)uploadTotalBytes -{ - if ( [self.requestMethod isEqualToString:@"GET"] ) - { - return 0; - } - else if ( [self.requestMethod isEqualToString:@"POST"] ) - { - return self.postLength; - } - - return 0; -} - -- (CGFloat)downloadPercent -{ - NSUInteger bytes1 = self.downloadBytes; - NSUInteger bytes2 = self.downloadTotalBytes; - - return bytes2 ? ((CGFloat)bytes1 / (CGFloat)bytes2) : 0.0f; -} - -- (NSUInteger)downloadBytes -{ - return [[self rawResponseData] length]; -} - -- (NSUInteger)downloadTotalBytes -{ - return self.contentLength; -} - -- (BOOL)is:(NSString *)text -{ - return [[self.url absoluteString] isEqualToString:text]; -} - -- (void)callResponders -{ - for ( NSObject * responder in _responders ) - { - if ( [responder isRequestResponder] ) - { - [responder handleRequest:self]; - } - } -} - -- (void)forwardResponder:(NSObject *)obj -{ - if ( [obj isRequestResponder] ) - { - [obj handleRequest:self]; - } -} - -- (void)changeState:(NSUInteger)state -{ - if ( state != _state ) - { - _state = state; - - if ( BeeRequest.STATE_SENDING == _state ) - { - _sendTimeStamp = [NSDate timeIntervalSinceReferenceDate]; - } - else if ( BeeRequest.STATE_RECVING == _state ) - { - _recvTimeStamp = [NSDate timeIntervalSinceReferenceDate]; - } - else if ( BeeRequest.STATE_FAILED == _state || BeeRequest.STATE_SUCCEED == _state || BeeRequest.STATE_CANCELLED == _state ) - { - _doneTimeStamp = [NSDate timeIntervalSinceReferenceDate]; - } - - [self callResponders]; - -// if ( [_responder isRequestResponder] ) -// { -// [_responder handleRequest:self]; -// } - - if ( self.whenUpdate ) - { - self.whenUpdate( self ); - } - } -} - -- (void)updateSendProgress -{ - _sendProgressed = YES; - - [self callResponders]; - -// if ( [_responder isRequestResponder] ) -// { -// [_responder handleRequest:self]; -// } - - if ( self.whenUpdate ) - { - self.whenUpdate( self ); - } - - _sendProgressed = NO; -} - -- (void)updateRecvProgress -{ - if ( _state == BeeRequest.STATE_SUCCEED || _state == BeeRequest.STATE_FAILED || _state == BeeRequest.STATE_CANCELLED ) - return; - - if ( self.didUseCachedResponse ) - return; - - _recvProgressed = YES; - - [self callResponders]; - -// if ( [_responder isRequestResponder] ) -// { -// [_responder handleRequest:self]; -// } - - if ( self.whenUpdate ) - { - self.whenUpdate( self ); - } - - _recvProgressed = NO; -} - -- (NSTimeInterval)timeCostPending -{ - return _sendTimeStamp - _initTimeStamp; -} - -- (NSTimeInterval)timeCostOverDNS -{ - return _recvTimeStamp - _sendTimeStamp; -} - -- (NSTimeInterval)timeCostRecving -{ - return _doneTimeStamp - _recvTimeStamp; -} - -- (NSTimeInterval)timeCostOverAir -{ - return _doneTimeStamp - _sendTimeStamp; -} - -- (BOOL)created -{ - return BeeRequest.STATE_CREATED == _state ? YES : NO; -} - -- (BOOL)sending -{ - return BeeRequest.STATE_SENDING == _state ? YES : NO; -} - -- (BOOL)recving -{ - return BeeRequest.STATE_RECVING == _state ? YES : NO; -} - -- (BOOL)succeed -{ - return BeeRequest.STATE_SUCCEED == _state ? YES : NO; -} - -- (BOOL)failed -{ - return BeeRequest.STATE_FAILED == _state ? YES : NO; -} - -- (BOOL)cancelled -{ - return BeeRequest.STATE_CANCELLED == _state ? YES : NO; -} - -- (BOOL)hasResponder:(id)responder -{ - return [_responders containsObject:responder]; -} - -- (void)addResponder:(id)responder -{ - [_responders addObjectNoRetain:responder]; -} - -- (void)removeResponder:(id)responder -{ - [_responders removeObjectNoRelease:responder]; -} - -- (void)removeAllResponders -{ - [_responders removeAllObjectsNoRelease]; -} - -@end - -#pragma mark - - -@interface BeeRequestQueue(Private) -- (BOOL)checkResourceBroken:(NSString *)url; - -- (BeeRequest *)GET:(NSString *)url sync:(BOOL)sync; -- (BeeRequest *)POST:(NSString *)url data:(NSData *)data sync:(BOOL)sync; -- (BeeRequest *)POST:(NSString *)url params:(NSDictionary *)kvs sync:(BOOL)sync; -- (BeeRequest *)POST:(NSString *)url files:(NSDictionary *)files params:(NSDictionary *)kvs sync:(BOOL)sync; - -- (void)cancelRequest:(BeeRequest *)request; -- (void)cancelRequestByResponder:(id)responder; -- (void)cancelAllRequests; - -- (void)blockURL:(NSString *)url; -- (void)unblockURL:(NSString *)url; - -- (BOOL)requesting:(NSString *)url; -- (BOOL)requesting:(NSString *)url byResponder:(id)responder; - -- (NSArray *)requests:(NSString *)url; -- (NSArray *)requests:(NSString *)url byResponder:(id)responder; - -@end - -#pragma mark - - -@implementation BeeRequestQueue - -@synthesize merge = _merge; -@synthesize online = _online; - -@synthesize blackListEnable = _blackListEnable; -@synthesize blackListTimeout = _blackListTimeout; -@synthesize blackList = _blackList; - -@synthesize bytesUpload = _bytesUpload; -@synthesize bytesDownload = _bytesDownload; - -@synthesize delay = _delay; -@synthesize requests = _requests; - -@synthesize whenCreate = _whenCreate; -@synthesize whenUpdate = _whenUpdate; - -+ (BOOL)isReachableViaWIFI -{ - return YES; -} - -+ (BOOL)isReachableViaWLAN -{ - return YES; -} - -+ (BOOL)isNetworkInUse -{ - return ([[BeeRequestQueue sharedInstance].requests count] > 0) ? YES : NO; -} - -+ (NSUInteger)bandwidthUsedPerSecond -{ - return [ASIHTTPRequest averageBandwidthUsedPerSecond]; -} - -+ (BeeRequestQueue *)sharedInstance -{ - static BeeRequestQueue * __sharedInstance = nil; - - @synchronized(self) - { - if ( nil == __sharedInstance ) - { - __sharedInstance = [[BeeRequestQueue alloc] init]; - -// [ASIHTTPRequest setShouldThrottleBandwidthForWWAN:YES]; -// [ASIHTTPRequest throttleBandwidthForWWANUsingLimit:32 * 1024]; // 32K - [ASIHTTPRequest setDefaultUserAgentString:@"Bee"]; - [[ASIHTTPRequest sharedQueue] setMaxConcurrentOperationCount:10]; - } - } - - return (BeeRequestQueue *)__sharedInstance; -} - -- (id)init -{ - self = [super init]; - if ( self ) - { - _delay = 0.1f; - _merge = YES; - _online = YES; - _requests = [[NSMutableArray alloc] init]; - - _blackListEnable = YES; - _blackListTimeout = DEFAULT_BLACKLIST_TIMEOUT; - _blackList = [[NSMutableDictionary alloc] init]; - } - - return self; -} - -- (void)setOnline:(BOOL)en -{ - _online = en; - - if ( NO == _online ) - { - [self cancelAllRequests]; - } -} - -- (void)dealloc -{ - [self cancelAllRequests]; - - [_requests removeAllObjects]; - [_requests release]; - - [_blackList removeAllObjects]; - [_blackList release]; - - self.whenCreate = nil; - self.whenUpdate = nil; - - [super dealloc]; -} - -- (BOOL)checkResourceBroken:(NSString *)url -{ - if ( _blackListEnable ) - { - NSDate * date = nil; - NSDate * now = [NSDate date]; - - date = [_blackList objectForKey:url]; - if ( date && ([date timeIntervalSince1970] - [now timeIntervalSince1970]) < _blackListTimeout ) - { - #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ - CC( @"resource broken: %@", url ); - #endif // #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ - - return YES; - } - } - - return NO; -} - -+ (BeeRequest *)GET:(NSString *)url -{ - return [[BeeRequestQueue sharedInstance] GET:url sync:NO]; -} - -- (BeeRequest *)GET:(NSString *)url sync:(BOOL)sync -{ - if ( NO == _online ) - return nil; - - if ( [self checkResourceBroken:url] ) - { - return nil; - } - - BeeRequest * request = nil; - - if ( NO == sync && _merge ) - { - for ( BeeRequest * req in _requests ) - { - if ( [req.url.absoluteString isEqualToString:url] ) - { - return req; - } - } - } - -#if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ - CC( @"GET %@\n", url ); -#endif // #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ - - request = [[BeeRequest alloc] initWithURL:[NSURL URLWithString:url]]; - request.timeOutSeconds = DEFAULT_GET_TIMEOUT; - request.requestMethod = @"GET"; - request.postBody = nil; - [request setDelegate:self]; - [request setDownloadProgressDelegate:self]; - [request setUploadProgressDelegate:self]; - - [request setNumberOfTimesToRetryOnTimeout:2]; -#if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 - [request setShouldContinueWhenAppEntersBackground:YES]; -#endif // #if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 - - [request setThreadPriority:0.5]; - [request setQueuePriority:NSOperationQueuePriorityLow]; - - [_requests addObject:request]; - - if ( self.whenCreate ) - { - self.whenCreate( request ); - } - - if ( sync ) - { - [request startSynchronous]; - } - else - { - if ( _delay ) - { - [request performSelector:@selector(startAsynchronous) - withObject:nil - afterDelay:_delay]; - } - else - { - [request startAsynchronous]; - } - } - - return [request autorelease]; -} - -+ (BeeRequest *)POST:(NSString *)url data:(NSData *)data -{ - return [[BeeRequestQueue sharedInstance] POST:url data:data sync:NO]; -} - -- (BeeRequest *)POST:(NSString *)url data:(NSData *)data sync:(BOOL)sync -{ - if ( NO == _online ) - return nil; - - BeeRequest * request = nil; - -#if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ - CC( @"POST %@\n", url ); -#endif // #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ - - request = [[BeeRequest alloc] initWithURL:[NSURL URLWithString:url]]; - request.timeOutSeconds = DEFAULT_POST_TIMEOUT; - request.requestMethod = @"POST"; - request.postFormat = ASIMultipartFormDataPostFormat; // ASIRawPostFormat; - request.postBody = [NSMutableData dataWithData:data]; - [request setDelegate:self]; - [request setDownloadProgressDelegate:self]; - [request setUploadProgressDelegate:self]; - [request setNumberOfTimesToRetryOnTimeout:2]; -#if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 - [request setShouldContinueWhenAppEntersBackground:YES]; -#endif // #if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 - - [request setThreadPriority:1.0]; - [request setQueuePriority:NSOperationQueuePriorityHigh]; - - [_requests addObject:request]; - - if ( self.whenCreate ) - { - self.whenCreate( request ); - } - - if ( sync ) - { - [request startSynchronous]; - } - else - { - if ( _delay ) - { - [request performSelector:@selector(startAsynchronous) - withObject:nil - afterDelay:_delay]; - } - else - { - [request startAsynchronous]; - } - } - - return [request autorelease]; -} - -+ (BeeRequest *)POST:(NSString *)url params:(NSDictionary *)kvs -{ - return [[BeeRequestQueue sharedInstance] POST:url params:kvs sync:NO]; -} - -- (BeeRequest *)POST:(NSString *)url params:(NSDictionary *)kvs sync:(BOOL)sync -{ - if ( NO == _online ) - return nil; - - BeeRequest * request = nil; - -#if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ - CC( @"POST %@\n", url ); -#endif // #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ - - request = [[BeeRequest alloc] initWithURL:[NSURL URLWithString:url]]; - request.timeOutSeconds = DEFAULT_POST_TIMEOUT; - request.requestMethod = @"POST"; - request.postFormat = ASIMultipartFormDataPostFormat; - [request setDelegate:self]; - [request setDownloadProgressDelegate:self]; - [request setUploadProgressDelegate:self]; - - [request setNumberOfTimesToRetryOnTimeout:2]; -#if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 - [request setShouldContinueWhenAppEntersBackground:YES]; -#endif // #if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 - - [request setThreadPriority:1.0]; - [request setQueuePriority:NSOperationQueuePriorityHigh]; - - NSArray * keys = [kvs allKeys]; - for ( NSString * key in keys ) - { - [request setPostValue:[kvs objectForKey:key] forKey:key]; - } - - [_requests addObject:request]; - - if ( self.whenCreate ) - { - self.whenCreate( request ); - } - - if ( sync ) - { - [request startSynchronous]; - } - else - { - if ( _delay ) - { - [request performSelector:@selector(startAsynchronous) - withObject:nil - afterDelay:_delay]; - } - else - { - [request startAsynchronous]; - } - } - - return [request autorelease]; -} - -+ (BeeRequest *)POST:(NSString *)url files:(NSDictionary *)files -{ - return [[BeeRequestQueue sharedInstance] POST:url files:files params:nil sync:NO]; -} - -+ (BeeRequest *)POST:(NSString *)url files:(NSDictionary *)files params:(NSDictionary *)kvs -{ - return [[BeeRequestQueue sharedInstance] POST:url files:files params:kvs sync:NO]; -} - -- (BeeRequest *)POST:(NSString *)url files:(NSDictionary *)files params:(NSDictionary *)kvs sync:(BOOL)sync -{ - if ( NO == _online ) - return nil; - - BeeRequest * request = nil; - -#if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ - CC( @"POST %@\n", url ); -#endif // #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ - - request = [[BeeRequest alloc] initWithURL:[NSURL URLWithString:url]]; - request.timeOutSeconds = DEFAULT_UPLOAD_TIMEOUT; - request.requestMethod = @"POST"; - request.postFormat = ASIMultipartFormDataPostFormat; - [request setDelegate:self]; - [request setDownloadProgressDelegate:self]; - [request setUploadProgressDelegate:self]; - - [request setNumberOfTimesToRetryOnTimeout:2]; -#if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 - [request setShouldContinueWhenAppEntersBackground:YES]; -#endif // #if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_4_0 - - [request setThreadPriority:1.0]; - [request setQueuePriority:NSOperationQueuePriorityHigh]; - - if ( kvs ) - { - NSArray * keys = [kvs allKeys]; - for ( NSString * key in keys ) - { - [request setPostValue:[kvs objectForKey:key] forKey:key]; - } - } - - if ( files ) - { - NSArray * fileNames = [files allKeys]; - for ( NSInteger i = 0; i < [fileNames count]; ++i ) - { - NSString * fileName = [fileNames objectAtIndex:i]; - NSObject * fileData = [files objectForKey:fileName]; - - if ( fileName && fileData ) - { - NSString * homePath = NSHomeDirectory(); - NSString * docsPath = [homePath stringByAppendingPathComponent:@"Documents"]; - NSString * filePath = [docsPath stringByAppendingPathComponent:fileName]; - - if ( [fileData isKindOfClass:[NSString class]] ) - { - NSString * string = (NSString *)fileData; - [string writeToFile:filePath - atomically:YES - encoding:NSUTF8StringEncoding - error:NULL]; - } - else if ( [fileData isKindOfClass:[NSData class]] ) - { - NSData * data = (NSData *)fileData; - [data writeToFile:filePath - options:NSDataWritingAtomic - error:NULL]; - } - else - { - NSAssert( 0, @"non-support type of file data" ); - } - - [request setFile:filePath forKey:fileName]; - } - } - } - - [_requests addObject:request]; - - if ( self.whenCreate ) - { - self.whenCreate( request ); - } - - if ( sync ) - { - [request startSynchronous]; - } - else - { - if ( _delay ) - { - [request performSelector:@selector(startAsynchronous) - withObject:nil - afterDelay:_delay]; - } - else - { - [request startAsynchronous]; - } - } - - return [request autorelease]; -} - -+ (BOOL)requesting:(NSString *)url -{ - return [[BeeRequestQueue sharedInstance] requesting:url]; -} - -- (BOOL)requesting:(NSString *)url -{ - for ( BeeRequest * request in _requests ) - { - if ( [[request.url absoluteString] isEqualToString:url] ) - { - return YES; - } - } - - return NO; -} - -+ (BOOL)requesting:(NSString *)url byResponder:(id)responder -{ - return [[BeeRequestQueue sharedInstance] requesting:url byResponder:responder]; -} - -- (BOOL)requesting:(NSString *)url byResponder:(id)responder -{ - for ( BeeRequest * request in _requests ) - { - if ( responder && NO == [request hasResponder:responder] /*request.responder != responder*/ ) - continue; - - if ( nil == url || [[request.url absoluteString] isEqualToString:url] ) - { - return YES; - } - } - - return NO; -} - -+ (NSArray *)requests:(NSString *)url -{ - return [[BeeRequestQueue sharedInstance] requests:url]; -} - -- (NSArray *)requests:(NSString *)url -{ - NSMutableArray * array = [NSMutableArray array]; - - for ( BeeRequest * request in _requests ) - { - if ( [[request.url absoluteString] isEqualToString:url] ) - { - [array addObject:request]; - } - } - - return array; -} - -+ (NSArray *)requests:(NSString *)url byResponder:(id)responder -{ - return [[BeeRequestQueue sharedInstance] requests:url byResponder:responder]; -} - -- (NSArray *)requests:(NSString *)url byResponder:(id)responder -{ - NSMutableArray * array = [NSMutableArray array]; - - for ( BeeRequest * request in _requests ) - { - if ( responder && NO == [request hasResponder:responder] /* request.responder != responder */ ) - continue; - - if ( nil == url || [[request.url absoluteString] isEqualToString:url] ) - { - [array addObject:request]; - } - } - - return array; -} - -+ (void)cancelRequest:(BeeRequest *)request -{ - [[BeeRequestQueue sharedInstance] cancelRequest:request]; -} - -- (void)cancelRequest:(BeeRequest *)request -{ - [NSObject cancelPreviousPerformRequestsWithTarget:request selector:@selector(startAsynchronous) object:nil]; - - if ( [_requests containsObject:request] ) - { - if ( request.created || request.sending || request.recving ) - { - [request changeState:BeeRequest.STATE_CANCELLED]; - - [request clearDelegatesAndCancel]; - [request removeAllResponders]; - } - - [_requests removeObject:request]; - } -} - -+ (void)cancelRequestByResponder:(id)responder -{ - [[BeeRequestQueue sharedInstance] cancelRequestByResponder:responder]; -} - -- (void)cancelRequestByResponder:(id)responder -{ - if ( nil == responder ) - { - [self cancelAllRequests]; - } - else - { - NSMutableArray * tempArray = [NSMutableArray array]; - - for ( BeeRequest * request in _requests ) - { - if ( [request hasResponder:responder] /* request.responder == responder */ ) - { - [tempArray addObject:request]; - } - } - - for ( BeeRequest * request in tempArray ) - { - [self cancelRequest:request]; - } - } -} - -+ (void)cancelAllRequests -{ - [[BeeRequestQueue sharedInstance] cancelAllRequests]; -} - -- (void)cancelAllRequests -{ - for ( BeeRequest * request in _requests ) - { - [self cancelRequest:request]; - } -} - -+ (void)blockURL:(NSString *)url -{ - [[BeeRequestQueue sharedInstance] blockURL:url]; -} - -- (void)blockURL:(NSString *)url -{ - [_blackList setObject:[NSDate date] forKey:url]; -} - -+ (void)unblockURL:(NSString *)url -{ - [[BeeRequestQueue sharedInstance] unblockURL:url]; -} - -- (void)unblockURL:(NSString *)url -{ - if ( [_blackList objectForKey:url] ) - { - NSDate * date = [NSDate dateWithTimeInterval:(_blackListTimeout + 1.0f) sinceDate:[NSDate date]]; - [_blackList setObject:date forKey:url]; - } -} - -- (NSArray *)requests -{ - return _requests; -} - -#pragma mark - -#pragma mark ASIHTTPRequestDelegate - -- (void)requestStarted:(ASIHTTPRequest *)request -{ - if ( NO == [request isKindOfClass:[BeeRequest class]] ) - return; - - BeeRequest * networkRequest = (BeeRequest *)request; - [networkRequest changeState:BeeRequest.STATE_SENDING]; - - _bytesUpload += request.postLength; - - if ( self.whenUpdate ) - { - self.whenUpdate( networkRequest ); - } -} - -- (void)request:(ASIHTTPRequest *)request didReceiveResponseHeaders:(NSDictionary *)responseHeaders -{ - if ( NO == [request isKindOfClass:[BeeRequest class]] ) - return; - - BeeRequest * networkRequest = (BeeRequest *)request; - [networkRequest changeState:BeeRequest.STATE_RECVING]; - - if ( self.whenUpdate ) - { - self.whenUpdate( networkRequest ); - } -} - -- (void)requestFinished:(ASIHTTPRequest *)request -{ - _bytesDownload += [[request rawResponseData] length]; - - if ( NO == [request isKindOfClass:[BeeRequest class]] ) - return; - - BeeRequest * networkRequest = (BeeRequest *)request; - -#if __BEE_DEVELOPMENT__ - CC( @"\nHTTP %d(%@)\n%@\n", - request.responseStatusCode, - request.responseStatusMessage, - [request.url absoluteString] ); -#endif - - if ( [request.requestMethod isEqualToString:@"GET"] ) - { - if ( request.responseStatusCode >= 400 && request.responseStatusCode < 500 ) - { - [self blockURL:[request.url absoluteString]]; - } - } - - if ( 200 == request.responseStatusCode ) - { - [networkRequest changeState:BeeRequest.STATE_SUCCEED]; - } - else - { - [networkRequest changeState:BeeRequest.STATE_FAILED]; - } - - [networkRequest clearDelegatesAndCancel]; - [networkRequest removeAllResponders]; - - [_requests removeObject:networkRequest]; - - if ( self.whenUpdate ) - { - self.whenUpdate( networkRequest ); - } -} - -- (void)requestFailed:(ASIHTTPRequest *)request -{ - if ( NO == [request isKindOfClass:[BeeRequest class]] ) - return; - - BeeRequest * networkRequest = (BeeRequest *)request; - - networkRequest.errorCode = -1; - [networkRequest changeState:BeeRequest.STATE_FAILED]; - - [networkRequest clearDelegatesAndCancel]; - [networkRequest removeAllResponders]; - - [_requests removeObject:networkRequest]; - - if ( self.whenUpdate ) - { - self.whenUpdate( networkRequest ); - } -} - -#pragma mark - - -- (void)request:(ASIHTTPRequest *)request willRedirectToURL:(NSURL *)newURL -{ - [self requestFailed:request]; -} - -- (void)requestRedirected:(ASIHTTPRequest *)request -{ - [self requestFailed:request]; -} - -- (void)authenticationNeededForRequest:(ASIHTTPRequest *)request -{ - [self requestFailed:request]; -} - -- (void)proxyAuthenticationNeededForRequest:(ASIHTTPRequest *)request -{ - [self requestFailed:request]; -} - -#pragma mark - - -// Called when the request receives some data - bytes is the length of that data -- (void)request:(ASIHTTPRequest *)request didReceiveBytes:(long long)bytes -{ - if ( NO == [request isKindOfClass:[BeeRequest class]] ) - return; - - BeeRequest * networkRequest = (BeeRequest *)request; - [networkRequest updateRecvProgress]; -} - -// Called when the request sends some data -// The first 32KB (128KB on older platforms) of data sent is not included in this amount because of limitations with the CFNetwork API -// bytes may be less than zero if a request needs to remove upload progress (probably because the request needs to run again) -- (void)request:(ASIHTTPRequest *)request didSendBytes:(long long)bytes -{ - if ( NO == [request isKindOfClass:[BeeRequest class]] ) - return; - - BeeRequest * networkRequest = (BeeRequest *)request; - [networkRequest updateSendProgress]; -} - -// Called when a request needs to change the length of the content to download -- (void)request:(ASIHTTPRequest *)request incrementDownloadSizeBy:(long long)newLength -{ - if ( NO == [request isKindOfClass:[BeeRequest class]] ) - return; - - BeeRequest * networkRequest = (BeeRequest *)request; - [networkRequest updateRecvProgress]; -} - -// Called when a request needs to change the length of the content to upload -// newLength may be less than zero when a request needs to remove the size of the internal buffer from progress tracking -- (void)request:(ASIHTTPRequest *)request incrementUploadSizeBy:(long long)newLength -{ - if ( NO == [request isKindOfClass:[BeeRequest class]] ) - return; - - BeeRequest * networkRequest = (BeeRequest *)request; - [networkRequest updateSendProgress]; -} - -@end diff --git a/BeeFramework/MVC/Bee_MVC.h b/BeeFramework/MVC/Bee_MVC.h new file mode 100644 index 0000000..7c614b6 --- /dev/null +++ b/BeeFramework/MVC/Bee_MVC.h @@ -0,0 +1,44 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_MVC.h +// + +#import "Bee_Controller.h" +#import "Bee_Message.h" +#import "Bee_MessageQueue.h" +#import "BeeMessage+HTTP.h" +#import "BeeMessage+JSON.h" +#import "BeeMessage+XML.h" +#import "NSObject+BeeMessage.h" + +#import "Bee_Model.h" + +#import "Bee_View.h" +#import "Bee_ViewController.h" diff --git a/BeeFramework/MVC/Controller/Bee_Controller.h b/BeeFramework/MVC/Controller/Bee_Controller.h new file mode 100644 index 0000000..748d137 --- /dev/null +++ b/BeeFramework/MVC/Controller/Bee_Controller.h @@ -0,0 +1,66 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_Controller.h +// + +#import "Bee_Precompile.h" +#import "Bee_Core.h" +#import "Bee_Message.h" + +#pragma mark - + +@interface BeeController : NSObject +{ + NSString * _prefix; + NSMutableDictionary * _mapping; +} + +@property (nonatomic, retain) NSString * prefix; +@property (nonatomic, retain) NSMutableDictionary * mapping; + +AS_SINGLETON( BeeController ); + ++ (NSString *)MESSAGE; // 消息类别 ++ (NSString *)MESSAGE_TYPE; // = MESSAGE + ++ (NSArray *)allControllers; + ++ (BeeController *)routes:(NSString *)message; + +- (void)load; +- (void)unload; + +- (void)index:(BeeMessage *)msg; +- (void)route:(BeeMessage *)msg; + +- (void)map:(NSString *)name action:(SEL)action; +- (void)map:(NSString *)name action:(SEL)action target:(id)target; + +@end diff --git a/BeeFramework/MVC/Controller/Bee_Controller.mm b/BeeFramework/MVC/Controller/Bee_Controller.mm new file mode 100644 index 0000000..458c90a --- /dev/null +++ b/BeeFramework/MVC/Controller/Bee_Controller.mm @@ -0,0 +1,228 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_Controller.h +// + +#import "Bee_Precompile.h" +#import "Bee_Core.h" +#import "Bee_Message.h" +#import "Bee_MessageQueue.h" +#import "Bee_Controller.h" + +#import "JSONKit.h" +#import + +#pragma mark - + +@implementation BeeController + +static NSMutableArray * __subControllers = nil; + +@synthesize prefix = _prefix; +@synthesize mapping = _mapping; + +DEF_SINGLETON( BeeController ); + ++ (NSString *)MESSAGE +{ + return [self MESSAGE]; +} + ++ (NSString *)MESSAGE_TYPE +{ + return [NSString stringWithFormat:@"message.%@", [self description]]; +} + ++ (BeeController *)routes:(NSString *)message +{ + BeeController * controller = nil; + + if ( __subControllers.count ) + { + for ( BeeController * subController in __subControllers ) + { + if ( [message hasPrefix:subController.prefix] ) + { + controller = subController; + break; + } + } + } + + if ( nil == controller ) + { + NSArray * array = [message componentsSeparatedByString:@"."]; + if ( array && array.count > 1 ) + { +// NSString * prefix = (NSString *)[array objectAtIndex:0]; + NSString * clazz = (NSString *)[array objectAtIndex:1]; + + Class rtti = NSClassFromString( clazz ); + if ( rtti ) + { + if ( class_respondsToSelector( rtti, @selector(sharedInstance) ) ) + { + controller = [rtti sharedInstance]; + } + else + { + controller = [[[rtti alloc] init] autorelease]; + } + + if ( controller ) + { + NSAssert( [message hasPrefix:controller.prefix], @"wrong prefix" ); + + if ( NO == [__subControllers containsObject:controller] ) + { + [__subControllers addObject:controller]; + } + } + } + } + } + + if ( nil == controller ) + { + controller = [BeeController sharedInstance]; + } + + return controller; +} + ++ (NSArray *)allControllers +{ + return __subControllers; +} + +#pragma mark - + +- (id)init +{ + self = [super init]; + if ( self ) + { + if ( nil == __subControllers ) + { + __subControllers = [[NSMutableArray alloc] init]; + } + + self.mapping = [NSMutableDictionary dictionary]; + self.prefix = [NSString stringWithFormat:@"message.%@", [[self class] description]]; + + [self load]; + + if ( NO == [__subControllers containsObject:self] ) + { + [__subControllers addObject:self]; + } + } + + return self; +} + +- (void)dealloc +{ + if ( [__subControllers containsObject:self] ) + { + [__subControllers removeObject:self]; + } + + [self unload]; + + self.mapping = nil; + self.prefix = nil; + + [super dealloc]; +} + +- (void)load +{ +} + +- (void)unload +{ +} + +- (void)index:(BeeMessage *)msg +{ + CC( @"unknown message '%@'", msg.message ); + + [msg setLastError:BeeMessage.ERROR_CODE_ROUTES + domain:BeeMessage.ERROR_DOMAIN_UNKNOWN + desc:@"No routes"]; +} + +- (void)route:(BeeMessage *)msg +{ + NSArray * array = [_mapping objectForKey:msg.message]; + if ( array && [array count] ) + { + id target = [array objectAtIndex:0]; + SEL action = (SEL)[[array objectAtIndex:1] unsignedIntValue]; + + [target performSelector:action withObject:msg]; +// [target performSelectorInBackground:action withObject:msg]; + } + else + { + NSArray * parts = [msg.message componentsSeparatedByString:@"."]; + if ( parts && parts.count ) + { + NSString * methodName = parts.lastObject; + if ( methodName && methodName.length ) + { + NSString * selectorName = [methodName stringByAppendingString:@":"]; + SEL selector = NSSelectorFromString(selectorName); + + if ( [self respondsToSelector:selector] ) + { + [self performSelector:selector withObject:msg]; + return; + } + } + } + + [self index:msg]; + } +} + +- (void)map:(NSString *)name action:(SEL)action +{ + [self map:name action:action target:self]; +} + +- (void)map:(NSString *)name action:(SEL)action target:(id)target +{ + NSArray * array = [NSArray arrayWithObjects:target, [NSNumber numberWithUnsignedInt:(NSUInteger)action], nil]; + [_mapping setObject:array forKey:name]; +} + +@end diff --git a/BeeFramework/MVC/Bee_Controller.h b/BeeFramework/MVC/Controller/Bee_Message.h similarity index 66% rename from BeeFramework/MVC/Bee_Controller.h rename to BeeFramework/MVC/Controller/Bee_Message.h index 9b00a0f..206c085 100644 --- a/BeeFramework/MVC/Bee_Controller.h +++ b/BeeFramework/MVC/Controller/Bee_Message.h @@ -27,7 +27,7 @@ // IN THE SOFTWARE. // // -// Bee_Controller.h +// Bee_Message.h // #import "Bee_Precompile.h" @@ -42,30 +42,19 @@ #pragma mark - @class BeeMessage; -@class BeeMessageQueue; -@class BeeController; -#pragma mark - - -@interface NSObject(BeeMessageResponder) - -- (BOOL)sendingMessage:(NSString *)msg; -- (void)cancelMessage:(NSString *)msg; -- (void)cancelMessages; - -- (BeeMessage *)message:(NSString *)msg; -- (BeeMessage *)message:(NSString *)msg timeoutSeconds:(NSUInteger)seconds; - -- (BeeMessage *)sendMessage:(NSString *)msg; -- (BeeMessage *)sendMessage:(NSString *)msg timeoutSeconds:(NSUInteger)seconds; - -- (void)handleMessage:(BeeMessage *)msg; - -@end +typedef void (^BeeMessageBlock)( BeeMessage * msg ); +typedef BeeMessage * (^BeeMessageBlockV)( void ); +typedef BeeMessage * (^BeeMessageBlockN)( id key, ... ); +typedef BeeMessage * (^BeeMessageBlockT)( NSTimeInterval time ); +typedef id (^BeeMessageObjectBlockN)( id key, ... ); #pragma mark - -typedef void (^BeeMessageBlock)( BeeMessage * msg ); +@protocol BeeMessageExecutor +- (void)index:(BeeMessage *)msg; +- (void)route:(BeeMessage *)msg; +@end #pragma mark - @@ -81,19 +70,17 @@ typedef void (^BeeMessageBlock)( BeeMessage * msg ); NSTimer * _timer; // 计时器,消息可以单独设置超时 NSTimeInterval _seconds; // 超时时长(秒) BOOL _useCache; // 是否使用Cache + BOOL _toldProgress; // 是否告知进度 BOOL _progressed; // 是否有新进度 - + NSInteger _nextState; // 消息状态(下一状态) NSInteger _state; // 消息状态 NSString * _message; // 消息名字,格式: @"xxx.yyy" NSMutableDictionary * _input; // 输入参数字典 NSMutableDictionary * _output; // 输出数据字典 id _responder; // 回调对象 - BeeController * _executer; // 所负责处理该消息的Controller - - BeeRequest * _request; // 网络请求 - NSData * _response; // 网络返回数据 + id _executer; // 所负责处理该消息的Controller NSString * _errorDomain; // 错误域 NSInteger _errorCode; // 错误码 @@ -127,25 +114,31 @@ AS_INT( STATE_SUCCEED ) // 消息处理成功(本地或网络) AS_INT( STATE_FAILED ) // 消息处理失败(本地或网络) AS_INT( STATE_CANCELLED ) // 消息被取消了 -@property (nonatomic, assign) BOOL unique; -@property (nonatomic, assign) BOOL disabled; -@property (nonatomic, assign) BOOL async; -@property (nonatomic, assign) BOOL timeout; -@property (nonatomic, assign) BOOL cached; -@property (nonatomic, assign) BOOL emitted; -@property (nonatomic, assign) BOOL oneDirection; -@property (nonatomic, assign) NSTimeInterval seconds; +@property (nonatomic, readonly) BeeMessageBlockN INPUT; +@property (nonatomic, readonly) BeeMessageBlockN OUTPUT; +@property (nonatomic, readonly) BeeMessageBlockT TIMEOUT; +@property (nonatomic, readonly) BeeMessageBlockV TOLD_PROGRESS; + +@property (nonatomic, assign) BOOL unique; // 是否同时只能发一个 +@property (nonatomic, assign) BOOL disabled; // 是否被禁止回调 +@property (nonatomic, assign) BOOL async; // 是否异步 +@property (nonatomic, assign) BOOL timeout; // 是否超时了 +@property (nonatomic, assign) BOOL cached; // 是否从缓存读取的 +@property (nonatomic, assign) BOOL emitted; // 是否被发送了 +@property (nonatomic, assign) BOOL oneDirection; // 是否单方向发送 +@property (nonatomic, assign) NSTimeInterval seconds; // 超时时间 @property (nonatomic, assign) BOOL useCache; + @property (nonatomic, assign) BOOL toldProgress; +@property (nonatomic, assign) BOOL progressed; + @property (nonatomic, assign) id responder; @property (nonatomic, assign) NSInteger nextState; @property (nonatomic, assign) NSInteger state; @property (nonatomic, retain) NSString * message; @property (nonatomic, retain) NSMutableDictionary * input; @property (nonatomic, retain) NSMutableDictionary * output; -@property (nonatomic, assign) BeeController * executer; -@property (nonatomic, retain) BeeRequest * request; -@property (nonatomic, retain) NSData * response; +@property (nonatomic, assign) id executer; @property (nonatomic, retain) NSString * errorDomain; @property (nonatomic, assign) NSInteger errorCode; @@ -163,18 +156,15 @@ AS_INT( STATE_CANCELLED ) // 消息被取消了 @property (nonatomic, assign) BOOL created; @property (nonatomic, assign) BOOL sending; -@property (nonatomic, assign) BOOL progressed; @property (nonatomic, assign) BOOL succeed; @property (nonatomic, assign) BOOL failed; @property (nonatomic, assign) BOOL cancelled; -@property (nonatomic, readonly) float uploadProgress; -@property (nonatomic, readonly) float downloadProgress; - @property (nonatomic, readonly) NSTimeInterval timeElapsed; // 整体经过时间 @property (nonatomic, readonly) NSTimeInterval timeCostPending; // 排队等待耗时 @property (nonatomic, readonly) NSTimeInterval timeCostOverAir; // 网络处理耗时 ++ (BeeMessage *)message; + (BeeMessage *)message:(NSString *)msg; + (BeeMessage *)message:(NSString *)msg timeoutSeconds:(NSUInteger)seconds; + (BeeMessage *)message:(NSString *)msg responder:(id)responder; @@ -183,10 +173,6 @@ AS_INT( STATE_CANCELLED ) // 消息被取消了 - (BeeMessage *)send; - (BeeMessage *)input:(id)first, ...; - (BeeMessage *)output:(id)first, ...; -- (BeeMessage *)inputJSON:(NSString *)json; -- (BeeMessage *)outputJSON:(NSString *)json; -- (BeeMessage *)inputDict:(NSDictionary *)dict; -- (BeeMessage *)outputDict:(NSDictionary *)dict; - (BeeMessage *)cancel; - (BeeMessage *)reset; @@ -205,72 +191,13 @@ AS_INT( STATE_CANCELLED ) // 消息被取消了 - (void)callResponder; - (void)forwardResponder:(NSObject *)obj; -@end - -#pragma mark - - -@interface BeeMessageQueue : NSObject -{ - BeeMessageBlock _whenCreate; - BeeMessageBlock _whenUpdate; - NSTimer * _runloopTimer; - BOOL _pause; -} - -AS_SINGLETON(BeeMessageQueue) - -@property (nonatomic, copy) BeeMessageBlock whenCreate; -@property (nonatomic, copy) BeeMessageBlock whenUpdate; -@property (nonatomic, retain) NSTimer * runloopTimer; -@property (nonatomic, assign) BOOL pause; - -- (NSArray *)allMessages; -- (NSArray *)pendingMessages; -- (NSArray *)sendingMessages; -- (NSArray *)finishedMessages; -- (NSArray *)messages:(NSString *)msgName; -- (NSArray *)messagesInSet:(NSArray *)msgNames; - -- (BOOL)sendMessage:(BeeMessage *)msg; -- (void)removeMessage:(BeeMessage *)msg; -- (void)cancelMessage:(NSString *)msg; -- (void)cancelMessage:(NSString *)msg byResponder:(id)responder; -- (void)cancelMessages; - -- (BOOL)sending:(NSString *)msg; -- (BOOL)sending:(NSString *)msg byResponder:(id)responder; - -- (void)enableResponder:(id)responder; -- (void)disableResponder:(id)responder; - -@end - -#pragma mark - - -@interface BeeController : NSObject -{ - NSString * _prefix; - NSMutableDictionary * _mapping; -} - -@property (nonatomic, retain) NSString * prefix; -@property (nonatomic, retain) NSMutableDictionary * mapping; - -AS_SINGLETON( BeeController ); - -+ (NSString *)MESSAGE; // 消息类别 - -+ (NSArray *)allControllers; - -+ (BeeController *)routes:(NSString *)message; - -- (void)load; -- (void)unload; - -- (void)index:(BeeMessage *)msg; -- (void)route:(BeeMessage *)msg; - -- (void)map:(NSString *)name action:(SEL)action; -- (void)map:(NSString *)name action:(SEL)action target:(id)target; +// internal use only +- (void)internalStartTimer; +- (void)internalStopTimer; +- (void)internalNotifySending; +- (void)internalNotifySucceed; +- (void)internalNotifyFailed; +- (void)internalNotifyCancelled; +- (void)internalNotifyProgressUpdated; @end diff --git a/BeeFramework/MVC/Bee_Controller.mm b/BeeFramework/MVC/Controller/Bee_Message.mm similarity index 52% rename from BeeFramework/MVC/Bee_Controller.mm rename to BeeFramework/MVC/Controller/Bee_Message.mm index 883bc36..3a65dbe 100644 --- a/BeeFramework/MVC/Bee_Controller.mm +++ b/BeeFramework/MVC/Controller/Bee_Message.mm @@ -27,80 +27,26 @@ // IN THE SOFTWARE. // // -// Bee_Controller.h +// Bee_Message.h // #import "Bee_Precompile.h" -#import "Bee_Singleton.h" +#import "Bee_Core.h" +#import "Bee_Message.h" +#import "Bee_MessageQueue.h" #import "Bee_Controller.h" -#import "Bee_Runtime.h" -#import "Bee_Log.h" -#import "JSONKit.h" #import -#undef DEFAULT_RUNLOOP_INTERVAL -#define DEFAULT_RUNLOOP_INTERVAL (0.1f) - -#undef DEFAULT_TIMEOUT_SECONDS -#define DEFAULT_TIMEOUT_SECONDS (60.0f) - #pragma mark - -@implementation NSObject(BeeMessageResponder) - -- (BOOL)sendingMessage:(NSString *)msg -{ - return [[BeeMessageQueue sharedInstance] sending:msg byResponder:self]; -} - -- (void)cancelMessage:(NSString *)msg -{ - [[BeeMessageQueue sharedInstance] cancelMessage:msg byResponder:self]; -} - -- (void)cancelMessages -{ - [[BeeMessageQueue sharedInstance] cancelMessage:nil byResponder:self]; -} - -- (BeeMessage *)message:(NSString *)msg -{ - return [self message:msg timeoutSeconds:0]; -} - -- (BeeMessage *)message:(NSString *)msg timeoutSeconds:(NSUInteger)seconds -{ - return [BeeMessage message:msg responder:self timeoutSeconds:seconds]; -} - -- (BeeMessage *)sendMessage:(NSString *)msg -{ - return [self sendMessage:msg timeoutSeconds:0]; -} - -- (BeeMessage *)sendMessage:(NSString *)msg timeoutSeconds:(NSUInteger)seconds -{ - return [[BeeMessage message:msg responder:self timeoutSeconds:seconds] send]; -} - -- (void)handleMessage:(BeeMessage *)msg -{ -} - -@end +#undef DEFAULT_TIMEOUT_SECONDS +#define DEFAULT_TIMEOUT_SECONDS (10.0f) #pragma mark - @interface BeeMessage(Private) - (void)didMessageTimeout; -- (void)internalStartTimer; -- (void)internalStopTimer; -- (void)internalNotifySending; -- (void)internalNotifySucceed; -- (void)internalNotifyFailed; -- (void)internalNotifyCancelled; -- (void)internalNotifyProgressUpdated; - (void)callResponder; @end @@ -125,6 +71,10 @@ @implementation BeeMessage DEF_INT( STATE_FAILED, 3 ) DEF_INT( STATE_CANCELLED, 4 ) +@dynamic INPUT; +@dynamic OUTPUT; +@dynamic TIMEOUT; + @synthesize unique = _unique; @synthesize disabled = _disabled; @synthesize async = _async; @@ -134,8 +84,10 @@ @implementation BeeMessage @synthesize oneDirection = _oneDirection; @synthesize seconds = _seconds; @synthesize useCache = _useCache; + @synthesize toldProgress = _toldProgress; @synthesize progressed = _progressed; + @synthesize responder = _responder; @synthesize nextState = _nextState; @synthesize state = _state; @@ -144,9 +96,6 @@ @implementation BeeMessage @synthesize output = _output; @synthesize executer = _executer; -@synthesize request = _request; -@synthesize response = _response; - @synthesize errorDomain = _errorDomain; @synthesize errorCode = _errorCode; @synthesize errorDesc = _errorDesc; @@ -167,9 +116,6 @@ @implementation BeeMessage @synthesize failed; @synthesize cancelled; -@synthesize uploadProgress; -@synthesize downloadProgress; - @synthesize timeElapsed; @synthesize timeCostPending; @synthesize timeCostOverAir; @@ -186,8 +132,6 @@ - (id)init _seconds = DEFAULT_TIMEOUT_SECONDS; _timer = nil; _useCache = NO; - _toldProgress = NO; - _progressed = NO; _nextState = BeeMessage.STATE_CREATED; _state = BeeMessage.STATE_CREATED; @@ -196,8 +140,6 @@ - (id)init _output = [[NSMutableDictionary alloc] init]; _responder = nil; _executer = nil; - _request = nil; - _response = nil; _errorCode = BeeMessage.ERROR_CODE_OK; _errorDomain = nil; @@ -234,8 +176,7 @@ - (void)dealloc [_message release]; [_input release]; [_output release]; - [_request release]; - [_response release]; + [_errorDomain release]; [_errorDesc release]; @@ -249,6 +190,11 @@ - (void)dealloc [super dealloc]; } ++ (BeeMessage *)message +{ + return [[[BeeMessage alloc] init] autorelease]; +} + + (BeeMessage *)message:(NSString *)msg { BeeMessage * bmsg = [[BeeMessage alloc] init]; @@ -385,21 +331,19 @@ - (void)internalNotifyProgressUpdated { if ( NO == _toldProgress ) return; - - CC( @"upload = %0.2f, download = %0.2f", [self uploadProgress], [self downloadProgress] ); _progressed = YES; - + if ( NO == self.disabled ) { if ( self.whenUpdate ) { self.whenUpdate( self ); } - + [self callResponder]; } - + _progressed = NO; } @@ -418,20 +362,53 @@ - (void)forwardResponder:(NSObject *)obj { // NSString * prefix = (NSString *)[array objectAtIndex:0]; NSString * clazz = (NSString *)[array objectAtIndex:1]; - - NSString * selectorName = [NSString stringWithFormat:@"handle%@:", clazz]; - SEL selector = NSSelectorFromString( selectorName ); - - if ( obj && [obj respondsToSelector:selector] ) + NSString * name = (NSString *)[array objectAtIndex:2]; + + #if defined(__BEE_SELECTOR_STYLE2__) && __BEE_SELECTOR_STYLE2__ { - [obj performSelector:selector withObject:self]; - return; + NSString * selectorName; + SEL selector; + + selectorName = [NSString stringWithFormat:@"handleMessage_%@_%@:", clazz, name]; + selector = NSSelectorFromString(selectorName); + + if ( [obj respondsToSelector:selector] ) + { + [obj performSelector:selector withObject:self]; + return; + } + + selectorName = [NSString stringWithFormat:@"handleMessage_%@:", clazz]; + selector = NSSelectorFromString(selectorName); + + if ( [obj respondsToSelector:selector] ) + { + [obj performSelector:selector withObject:self]; + return; + } } - } + #endif // #if defined(__BEE_SELECTOR_STYLE2__) && __BEE_SELECTOR_STYLE2__ + #if defined(__BEE_SELECTOR_STYLE1__) && __BEE_SELECTOR_STYLE1__ + { + NSString * selectorName; + SEL selector; + + selectorName = [NSString stringWithFormat:@"handle%@:", clazz]; + selector = NSSelectorFromString( selectorName ); + + if ( [obj respondsToSelector:selector] ) + { + [obj performSelector:selector withObject:self]; + return; + } + } + #endif // #if defined(__BEE_SELECTOR_STYLE1__) && __BEE_SELECTOR_STYLE1__ + } + if ( obj && [obj respondsToSelector:@selector(handleMessage:)] ) { - [obj handleMessage:self]; + [obj handleMessage:self]; } } @@ -494,42 +471,6 @@ - (BeeMessage *)output:(id)first, ... return self; } -- (BeeMessage *)inputJSON:(NSString *)json -{ - NSObject * obj = [json objectFromJSONString]; - - if ( [obj isKindOfClass:[NSDictionary class]] ) - { - [self.input addEntriesFromDictionary:(NSDictionary *)obj]; - } - - return self; -} - -- (BeeMessage *)outputJSON:(NSString *)json -{ - NSObject * obj = [json objectFromJSONString]; - - if ( [obj isKindOfClass:[NSDictionary class]] ) - { - [self.output addEntriesFromDictionary:(NSDictionary *)obj]; - } - - return self; -} - -- (BeeMessage *)inputDict:(NSDictionary *)dict -{ - [self.input addEntriesFromDictionary:dict]; - return self; -} - -- (BeeMessage *)outputDict:(NSDictionary *)dict -{ - [self.output addEntriesFromDictionary:dict]; - return self; -} - - (BeeMessage *)cancel { if ( NO == _emitted || nil == _executer ) @@ -546,7 +487,6 @@ - (BeeMessage *)reset self.responder = nil; self.whenUpdate = nil; - self.request = nil; _initTimeStamp = [NSDate timeIntervalSinceReferenceDate]; _sendTimeStamp = _initTimeStamp; @@ -555,38 +495,6 @@ - (BeeMessage *)reset return self; } -- (float)uploadProgress -{ - if ( _request ) - { - unsigned long long sent = [_request totalBytesSent]; - unsigned long long total = [_request postLength]; - CC( @"%@, sent = %d, total = %d", self.message, sent, total ); - - return (sent * 1.0f) / (total * 1.0f); - } - else - { - return 0.0f; - } -} - -- (float)downloadProgress -{ - if ( _request ) - { - unsigned long long recv = [_request totalBytesRead]; - unsigned long long total = [_request contentLength]; - CC( @"%@, recv = %d, total = %d", self.message, recv, total ); - - return (recv * 1.0f) / (total * 1.0f); - } - else - { - return 0.0f; - } -} - - (NSTimeInterval)timeElapsed { return _recvTimeStamp - _initTimeStamp; @@ -753,8 +661,15 @@ - (void)changeState:(NSInteger)newState if ( nil == self.executer ) return; } - - [_executer route:self]; + + if ( [_executer respondsToSelector:@selector(route:)] ) + { + [_executer route:self]; + } + else + { + [_executer index:self]; + } if ( BeeMessage.ERROR_CODE_OK != _errorCode ) { @@ -834,560 +749,57 @@ - (void)changeState:(NSInteger)newState } } -- (void)handleRequest:(BeeRequest *)request +- (BeeMessageBlockN)INPUT { - if ( request.sending ) - { - self.request = request; - } - else if ( request.sendProgressed ) - { - [self internalNotifyProgressUpdated]; - } - else if ( request.recving ) - { - } - else if ( request.recvProgressed ) - { - [self internalNotifyProgressUpdated]; - } - else if ( request.succeed ) + BeeMessageBlockN block = ^ BeeMessage * ( id first, ... ) { - self.request = nil; - - self.response = [request responseData]; + va_list args; + va_start( args, first ); - [self changeState:BeeMessage.STATE_SUCCEED]; - } - else if ( request.failed ) - { - self.request = nil; + NSString * key = (NSString *)first; + NSObject * value = va_arg( args, NSObject * ); - if ( self.timeout ) - { - self.errorDomain = BeeMessage.ERROR_DOMAIN_SERVER; - self.errorCode = BeeMessage.ERROR_CODE_TIMEOUT; - self.errorDesc = @"timeout"; - } - else + if ( key && value ) { - self.errorDomain = BeeMessage.ERROR_DOMAIN_NETWORK; - self.errorCode = request.errorCode; - self.errorDesc = nil; + [self.input setObject:value atPath:key]; } - [self changeState:BeeMessage.STATE_FAILED]; - } - else if ( request.cancelled ) - { - self.request = nil; - - [self changeState:BeeMessage.STATE_CANCELLED]; - } -} - -@end - -#pragma mark - - -@interface BeeMessageQueue(Private) -- (void)runloop; -@end - -#pragma mark - - -@implementation BeeMessageQueue - -static NSMutableArray * __sharedQueue = nil; - -@synthesize whenCreate = _whenCreate; -@synthesize whenUpdate = _whenUpdate; -@synthesize runloopTimer = _runloopTimer; -@synthesize pause = _pause; - -DEF_SINGLETON(BeeMessageQueue); - -- (NSArray *)allMessages -{ - return __sharedQueue; -} - -- (NSArray *)pendingMessages -{ - NSMutableArray * array = [NSMutableArray array]; - - for ( BeeMessage * bmsg in __sharedQueue ) - { - if ( bmsg.created ) - { - [array addObject:bmsg]; - } - } - - return array; -} - -- (NSArray *)sendingMessages -{ - NSMutableArray * array = [NSMutableArray array]; - - for ( BeeMessage * msg in __sharedQueue ) - { - if ( msg.sending ) - { - [array addObject:msg]; - } - } - - return array; -} - -- (NSArray *)finishedMessages -{ - NSMutableArray * array = [NSMutableArray array]; - - for ( BeeMessage * bmsg in __sharedQueue ) - { - if ( bmsg.succeed || bmsg.failed || bmsg.cancelled ) - { - [array addObject:bmsg]; - } - } - - return array; -} - -- (NSArray *)messages:(NSString *)msgName -{ - if ( nil == msgName ) - { - return __sharedQueue; - } - else - { - NSMutableArray * array = [NSMutableArray array]; - - for ( BeeMessage * msg in __sharedQueue ) - { - if ( [msg.message isEqual:msgName] ) - { - [array addObject:msg]; - } - } - - return array; - } -} - -- (NSArray *)messagesInSet:(NSArray *)msgNames -{ - NSMutableArray * array = [NSMutableArray array]; - - for ( BeeMessage * msg in __sharedQueue ) - { - for ( NSString * msgName in msgNames ) - { - if ( [msg.message isEqual:msgName] ) - { - [array addObject:msg]; - break; - } - } - } - - return array; -} - -- (BOOL)sendMessage:(BeeMessage *)msg -{ - if ( [__sharedQueue containsObject:msg] ) - return NO; - - if ( msg.unique ) - { - for ( BeeMessage * inqueue in __sharedQueue ) - { - if ( [inqueue isTwinWith:msg] ) - return NO; - } - } - - [msg setSending:YES]; - - [__sharedQueue addObject:msg]; - return YES; -} - -- (void)removeMessage:(BeeMessage *)msg -{ - [__sharedQueue removeObject:msg]; -} - -- (void)cancelMessage:(NSString *)msg -{ - if ( nil == msg ) - { - [BeeRequestQueue cancelAllRequests]; - - [__sharedQueue removeAllObjects]; - } - else - { - NSUInteger count = [__sharedQueue count]; - BeeMessage * bmsg; - - for ( NSUInteger i = count; i > 0; --i ) - { - bmsg = [__sharedQueue objectAtIndex:(i - 1)]; - if ( msg && NO == [msg isEqualToString:bmsg.message] ) - continue; - - [bmsg changeState:BeeMessage.STATE_CANCELLED]; - } - } -} - -- (BOOL)sending:(NSString *)msg -{ - if ( nil == msg ) - { - return ([__sharedQueue count] > 0) ? YES : NO; - } - else - { - BeeMessage * bmsg = nil; - - NSUInteger count = [__sharedQueue count]; - for ( NSUInteger i = count; i > 0; --i ) - { - bmsg = [__sharedQueue objectAtIndex:(i - 1)]; - if ( YES == [msg isEqualToString:bmsg.message] ) - { - if ( bmsg.created || bmsg.sending ) - { - return YES; - } - else - { - return NO; - } - } - } - - return NO; - } -} - -- (BOOL)sending:(NSString *)msg byResponder:(id)responder -{ - BeeMessage * bmsg = nil; - - NSUInteger count = [__sharedQueue count]; - for ( NSUInteger i = count; i > 0; --i ) - { - bmsg = [__sharedQueue objectAtIndex:(i - 1)]; - if ( responder && bmsg.responder != responder ) - continue; - - if ( nil == msg || [msg isEqualToString:bmsg.message] ) - { - if ( bmsg.created || bmsg.sending ) - { - return YES; - } - else - { - return NO; - } - } - } - - return NO; -} - -- (void)enableResponder:(id)responder -{ - NSUInteger count = [__sharedQueue count]; - BeeMessage * bmsg; - - for ( NSUInteger i = count; i > 0; --i ) - { - bmsg = [__sharedQueue objectAtIndex:(i - 1)]; - if ( responder && bmsg.responder != responder ) - continue; - - bmsg.disabled = NO; - } -} - -- (void)disableResponder:(id)responder -{ - NSUInteger count = [__sharedQueue count]; - BeeMessage * bmsg; + return self; + }; - for ( NSUInteger i = count; i > 0; --i ) - { - bmsg = [__sharedQueue objectAtIndex:(i - 1)]; - if ( responder && bmsg.responder != responder ) - continue; - - bmsg.disabled = YES; - } + return [[block copy] autorelease]; } -- (void)cancelMessage:(NSString *)msg byResponder:(id)responder +- (BeeMessageBlockN)OUTPUT { - NSUInteger count = [__sharedQueue count]; - BeeMessage * bmsg; - - for ( NSUInteger i = count; i > 0; --i ) + BeeMessageBlockN block = ^ BeeMessage * ( id first, ... ) { - bmsg = [__sharedQueue objectAtIndex:(i - 1)]; - if ( responder && bmsg.responder != responder ) - continue; + va_list args; + va_start( args, first ); - if ( msg && NO == [msg isEqualToString:bmsg.message] ) - continue; + NSString * key = (NSString *)first; + NSObject * value = va_arg( args, NSObject * ); - [bmsg changeState:BeeMessage.STATE_CANCELLED]; - } -} - -- (void)cancelMessages -{ - [BeeRequestQueue cancelAllRequests]; - - [__sharedQueue removeAllObjects]; -} - -#pragma mark - - -- (id)init -{ - self = [super init]; - if ( self ) - { - if ( nil == __sharedQueue ) + if ( key && value ) { - __sharedQueue = [[NSMutableArray alloc] init]; + [self.output setObject:value atPath:key]; } - if ( nil == self.runloopTimer ) - { - self.runloopTimer = [NSTimer scheduledTimerWithTimeInterval:DEFAULT_RUNLOOP_INTERVAL - target:self - selector:@selector(runloop) - userInfo:nil - repeats:YES]; - } - } - - return self; -} - -- (void)runloop -{ - if ( _pause ) - return; - - for ( BeeMessage * bmsg in __sharedQueue ) - { - [bmsg runloop]; - } -} - -- (void)dealloc -{ - [_runloopTimer invalidate]; - _runloopTimer = nil; - - self.whenCreate = nil; - self.whenUpdate = nil; + return self; + }; - [super dealloc]; + return [[block copy] autorelease]; } -@end - -#pragma mark - - -@implementation BeeController - -static NSMutableArray * __subControllers = nil; - -@synthesize prefix = _prefix; -@synthesize mapping = _mapping; - -DEF_SINGLETON( BeeController ); - -+ (NSString *)MESSAGE -{ - return [NSString stringWithFormat:@"message.%@", [self description]]; -} - -+ (BeeController *)routes:(NSString *)message +- (BeeMessageBlockT)TIMEOUT { - BeeController * controller = nil; - - if ( __subControllers.count ) + BeeMessageBlockT block = ^ BeeMessage * ( NSTimeInterval time ) { - for ( BeeController * subController in __subControllers ) - { - if ( [message hasPrefix:subController.prefix] ) - { - controller = subController; - break; - } - } - } - - if ( nil == controller ) - { - NSArray * array = [message componentsSeparatedByString:@"."]; - if ( array && array.count > 1 ) - { -// NSString * prefix = (NSString *)[array objectAtIndex:0]; - NSString * clazz = (NSString *)[array objectAtIndex:1]; - - Class rtti = NSClassFromString( clazz ); - if ( rtti ) - { - if ( class_respondsToSelector( rtti, @selector(sharedInstance) ) ) - { - controller = [rtti sharedInstance]; - } - else - { - controller = [[[rtti alloc] init] autorelease]; - } - - if ( controller ) - { - NSAssert( [message hasPrefix:controller.prefix], @"wrong prefix" ); - - if ( NO == [__subControllers containsObject:controller] ) - { - [__subControllers addObject:controller]; - } - } - } - } - } - - if ( nil == controller ) - { - controller = [BeeController sharedInstance]; - } - - return controller; -} - -+ (NSArray *)allControllers -{ - return __subControllers; -} - -#pragma mark - - -- (id)init -{ - self = [super init]; - if ( self ) - { - if ( nil == __subControllers ) - { - __subControllers = [[NSMutableArray alloc] init]; - } - - self.mapping = [NSMutableDictionary dictionary]; - self.prefix = [NSString stringWithFormat:@"message.%@", [[self class] description]]; - - [self load]; - - if ( NO == [__subControllers containsObject:self] ) - { - [__subControllers addObject:self]; - } - } - - return self; -} - -- (void)dealloc -{ - if ( [__subControllers containsObject:self] ) - { - [__subControllers removeObject:self]; - } - - [self unload]; - - self.mapping = nil; - self.prefix = nil; + self.seconds = time; + return self; + }; - [super dealloc]; -} - -- (void)load -{ -} - -- (void)unload -{ -} - -- (void)index:(BeeMessage *)msg -{ - CC( @"unknown message '%@'", msg.message ); - - [msg setLastError:BeeMessage.ERROR_CODE_ROUTES - domain:BeeMessage.ERROR_DOMAIN_UNKNOWN - desc:@"No routes"]; -} - -- (void)route:(BeeMessage *)msg -{ - NSArray * array = [_mapping objectForKey:msg.message]; - if ( array && [array count] ) - { - id target = [array objectAtIndex:0]; - SEL action = (SEL)[[array objectAtIndex:1] unsignedIntValue]; - - [target performSelector:action withObject:msg]; -// [target performSelectorInBackground:action withObject:msg]; - } - else - { - NSArray * parts = [msg.message componentsSeparatedByString:@"."]; - if ( parts && parts.count ) - { - NSString * methodName = parts.lastObject; - if ( methodName && methodName.length ) - { - NSString * selectorName = [methodName stringByAppendingString:@":"]; - SEL selector = NSSelectorFromString(selectorName); - - if ( [self respondsToSelector:selector] ) - { - [self performSelector:selector withObject:msg]; - return; - } - } - } - - [self index:msg]; - } -} - -- (void)map:(NSString *)name action:(SEL)action -{ - [self map:name action:action target:self]; -} - -- (void)map:(NSString *)name action:(SEL)action target:(id)target -{ - NSArray * array = [NSArray arrayWithObjects:target, [NSNumber numberWithUnsignedInt:(NSUInteger)action], nil]; - [_mapping setObject:array forKey:name]; + return [[block copy] autorelease]; } @end diff --git a/BeeFramework/MVC/Controller/Bee_MessageQueue.h b/BeeFramework/MVC/Controller/Bee_MessageQueue.h new file mode 100644 index 0000000..100d368 --- /dev/null +++ b/BeeFramework/MVC/Controller/Bee_MessageQueue.h @@ -0,0 +1,75 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_MessageQueue.h +// + +#import "Bee_Precompile.h" +#import "Bee_Singleton.h" +#import "Bee_Message.h" + +#pragma mark - + +@interface BeeMessageQueue : NSObject +{ + BeeMessageBlock _whenCreate; + BeeMessageBlock _whenUpdate; + NSTimer * _timer; + BOOL _pause; +} + +AS_SINGLETON(BeeMessageQueue) + +@property (nonatomic, copy) BeeMessageBlock whenCreate; +@property (nonatomic, copy) BeeMessageBlock whenUpdate; + +@property (nonatomic, retain) NSTimer * timer; +@property (nonatomic, assign) BOOL pause; + +@property (nonatomic, readonly) NSArray * allMessages; +@property (nonatomic, readonly) NSArray * pendingMessages; +@property (nonatomic, readonly) NSArray * sendingMessages; +@property (nonatomic, readonly) NSArray * finishedMessages; + +- (NSArray *)messages:(NSString *)msgName; +- (NSArray *)messagesInSet:(NSArray *)msgNames; + +- (BOOL)sendMessage:(BeeMessage *)msg; +- (void)removeMessage:(BeeMessage *)msg; +- (void)cancelMessage:(NSString *)msg; +- (void)cancelMessage:(NSString *)msg byResponder:(id)responder; +- (void)cancelMessages; + +- (BOOL)sending:(NSString *)msg; +- (BOOL)sending:(NSString *)msg byResponder:(id)responder; + +- (void)enableResponder:(id)responder; +- (void)disableResponder:(id)responder; + +@end diff --git a/BeeFramework/MVC/Controller/Bee_MessageQueue.mm b/BeeFramework/MVC/Controller/Bee_MessageQueue.mm new file mode 100644 index 0000000..d1c1be6 --- /dev/null +++ b/BeeFramework/MVC/Controller/Bee_MessageQueue.mm @@ -0,0 +1,389 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_MessageQueue.h +// + +#import "Bee_Precompile.h" +#import "Bee_Core.h" +#import "Bee_Message.h" +#import "Bee_MessageQueue.h" +#import "Bee_Controller.h" + +#import + +#pragma mark - + +#undef DEFAULT_RUNLOOP_INTERVAL +#define DEFAULT_RUNLOOP_INTERVAL (0.1f) + +#pragma mark - + +@interface BeeMessageQueue(Private) +- (void)runloop; +@end + +#pragma mark - + +@implementation BeeMessageQueue + +static NSMutableArray * __sharedQueue = nil; + +@synthesize whenCreate = _whenCreate; +@synthesize whenUpdate = _whenUpdate; +@synthesize timer = _timer; +@synthesize pause = _pause; + +DEF_SINGLETON(BeeMessageQueue); + +- (NSArray *)allMessages +{ + return __sharedQueue; +} + +- (NSArray *)pendingMessages +{ + NSMutableArray * array = [NSMutableArray array]; + + NSArray * queued = [[NSArray alloc] initWithArray:__sharedQueue]; + + for ( BeeMessage * bmsg in queued ) + { + if ( bmsg.created ) + { + [array addObject:bmsg]; + } + } + + [queued release]; + + return array; +} + +- (NSArray *)sendingMessages +{ + NSMutableArray * array = [NSMutableArray array]; + + NSArray * queued = [[NSArray alloc] initWithArray:__sharedQueue]; + + for ( BeeMessage * msg in queued ) + { + if ( msg.sending ) + { + [array addObject:msg]; + } + } + + [queued release]; + + return array; +} + +- (NSArray *)finishedMessages +{ + NSMutableArray * array = [NSMutableArray array]; + + NSArray * queued = [[NSArray alloc] initWithArray:__sharedQueue]; + + for ( BeeMessage * bmsg in queued ) + { + if ( bmsg.succeed || bmsg.failed || bmsg.cancelled ) + { + [array addObject:bmsg]; + } + } + + [queued release]; + + return array; +} + +- (NSArray *)messages:(NSString *)msgName +{ + if ( nil == msgName ) + { + return __sharedQueue; + } + else + { + NSMutableArray * array = [NSMutableArray array]; + + NSArray * queued = [[NSArray alloc] initWithArray:__sharedQueue]; + + for ( BeeMessage * msg in queued ) + { + if ( [msg.message isEqual:msgName] ) + { + [array addObject:msg]; + } + } + + [queued release]; + + return array; + } +} + +- (NSArray *)messagesInSet:(NSArray *)msgNames +{ + NSMutableArray * array = [NSMutableArray array]; + + NSArray * queued = [[NSArray alloc] initWithArray:__sharedQueue]; + + for ( BeeMessage * msg in queued ) + { + for ( NSString * msgName in msgNames ) + { + if ( [msg.message isEqual:msgName] ) + { + [array addObject:msg]; + break; + } + } + } + + [queued release]; + + return array; +} + +- (BOOL)sendMessage:(BeeMessage *)msg +{ + if ( [__sharedQueue containsObject:msg] ) + return NO; + + if ( msg.unique ) + { + for ( BeeMessage * inqueue in __sharedQueue ) + { + if ( [inqueue isTwinWith:msg] ) + return NO; + } + } + + [msg setSending:YES]; + + [__sharedQueue addObject:msg]; + return YES; +} + +- (void)removeMessage:(BeeMessage *)msg +{ + [__sharedQueue removeObject:msg]; +} + +- (void)cancelMessage:(NSString *)msg +{ + if ( nil == msg ) + { + [BeeRequestQueue cancelAllRequests]; + + [__sharedQueue removeAllObjects]; + } + else + { + NSUInteger count = [__sharedQueue count]; + BeeMessage * bmsg; + + for ( NSUInteger i = count; i > 0; --i ) + { + bmsg = [__sharedQueue objectAtIndex:(i - 1)]; + if ( msg && NO == [msg isEqualToString:bmsg.message] ) + continue; + + [bmsg changeState:BeeMessage.STATE_CANCELLED]; + } + } +} + +- (BOOL)sending:(NSString *)msg +{ + if ( nil == msg ) + { + return ([__sharedQueue count] > 0) ? YES : NO; + } + else + { + BeeMessage * bmsg = nil; + + NSUInteger count = [__sharedQueue count]; + for ( NSUInteger i = count; i > 0; --i ) + { + bmsg = [__sharedQueue objectAtIndex:(i - 1)]; + if ( YES == [msg isEqualToString:bmsg.message] ) + { + if ( bmsg.created || bmsg.sending ) + { + return YES; + } + else + { + return NO; + } + } + } + + return NO; + } +} + +- (BOOL)sending:(NSString *)msg byResponder:(id)responder +{ + BeeMessage * bmsg = nil; + + NSUInteger count = [__sharedQueue count]; + for ( NSUInteger i = count; i > 0; --i ) + { + bmsg = [__sharedQueue objectAtIndex:(i - 1)]; + if ( responder && bmsg.responder != responder ) + continue; + + if ( nil == msg || [msg isEqualToString:bmsg.message] ) + { + if ( bmsg.created || bmsg.sending ) + { + return YES; + } + else + { + return NO; + } + } + } + + return NO; +} + +- (void)enableResponder:(id)responder +{ + NSUInteger count = [__sharedQueue count]; + BeeMessage * bmsg; + + for ( NSUInteger i = count; i > 0; --i ) + { + bmsg = [__sharedQueue objectAtIndex:(i - 1)]; + if ( responder && bmsg.responder != responder ) + continue; + + bmsg.disabled = NO; + } +} + +- (void)disableResponder:(id)responder +{ + NSUInteger count = [__sharedQueue count]; + BeeMessage * bmsg; + + for ( NSUInteger i = count; i > 0; --i ) + { + bmsg = [__sharedQueue objectAtIndex:(i - 1)]; + if ( responder && bmsg.responder != responder ) + continue; + + bmsg.disabled = YES; + } +} + +- (void)cancelMessage:(NSString *)msg byResponder:(id)responder +{ + NSUInteger count = [__sharedQueue count]; + BeeMessage * bmsg; + + for ( NSUInteger i = count; i > 0; --i ) + { + bmsg = [__sharedQueue objectAtIndex:(i - 1)]; + if ( responder && bmsg.responder != responder ) + continue; + + if ( msg && NO == [msg isEqualToString:bmsg.message] ) + continue; + + [bmsg changeState:BeeMessage.STATE_CANCELLED]; + } +} + +- (void)cancelMessages +{ + [BeeRequestQueue cancelAllRequests]; + + [__sharedQueue removeAllObjects]; +} + +#pragma mark - + +- (id)init +{ + self = [super init]; + if ( self ) + { + if ( nil == __sharedQueue ) + { + __sharedQueue = [[NSMutableArray alloc] init]; + } + + if ( nil == self.timer ) + { + self.timer = [NSTimer scheduledTimerWithTimeInterval:DEFAULT_RUNLOOP_INTERVAL + target:self + selector:@selector(runloop) + userInfo:nil + repeats:YES]; + } + } + + return self; +} + +- (void)runloop +{ + if ( _pause ) + return; + + NSArray * queued = [[NSArray alloc] initWithArray:__sharedQueue]; + + for ( BeeMessage * bmsg in queued ) + { + [bmsg runloop]; + } + + [queued release]; +} + +- (void)dealloc +{ + [_timer invalidate]; + _timer = nil; + + self.whenCreate = nil; + self.whenUpdate = nil; + + [super dealloc]; +} + +@end diff --git a/BeeFramework/MVC/Controller/Extension/BeeMessage+ActiveRecord.h b/BeeFramework/MVC/Controller/Extension/BeeMessage+ActiveRecord.h new file mode 100644 index 0000000..c29c323 --- /dev/null +++ b/BeeFramework/MVC/Controller/Extension/BeeMessage+ActiveRecord.h @@ -0,0 +1,45 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// BeeMessage+ActiveRecord.h +// + +#import "Bee_Precompile.h" +#import "Bee_Message.h" +#import "Bee_Network.h" +#import "Bee_ActiveRecord.h" + +#pragma mark - + +@interface BeeMessage(ActiveRecord) + +@property (nonatomic, readonly) BeeActiveRecord * responseRecord; +@property (nonatomic, readonly) NSArray * responseRecordArray; + +@end diff --git a/BeeFramework/MVC/Controller/Extension/BeeMessage+ActiveRecord.m b/BeeFramework/MVC/Controller/Extension/BeeMessage+ActiveRecord.m new file mode 100644 index 0000000..081fe74 --- /dev/null +++ b/BeeFramework/MVC/Controller/Extension/BeeMessage+ActiveRecord.m @@ -0,0 +1,61 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// BeeMessage+ActiveRecord.h +// + +#import "Bee_Precompile.h" +#import "Bee_Network.h" +#import "BeeMessage+JSON.h" +#import "BeeMessage+HTTP.h" +#import "BeeMessage+ActiveRecord.h" + +#import "JSONKit.h" +#import + +#pragma mark - + +@implementation BeeMessage(ActiveRecord) + +@dynamic responseRecord; +@dynamic responseRecordArray; + +- (BeeActiveRecord *)responseRecord +{ + // TODO: + return nil; +} + +- (NSArray *)responseRecordArray +{ + // TODO: + return nil; +} + +@end diff --git a/BeeFramework/MVC/Controller/Extension/BeeMessage+HTTP.h b/BeeFramework/MVC/Controller/Extension/BeeMessage+HTTP.h new file mode 100644 index 0000000..83daa9c --- /dev/null +++ b/BeeFramework/MVC/Controller/Extension/BeeMessage+HTTP.h @@ -0,0 +1,49 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// BeeMessage+HTTP.h +// + +#import "Bee_Precompile.h" +#import "Bee_Message.h" +#import "Bee_Network.h" + +#pragma mark - + +@interface BeeMessage(HTTP) + +@property (nonatomic, readonly) float uploadProgress; +@property (nonatomic, readonly) float downloadProgress; + +@property (nonatomic, readonly) BOOL requesting; +@property (nonatomic, readonly) BeeRequest * request; +@property (nonatomic, readonly) NSData * response; +@property (nonatomic, readonly) NSString * responseString; + +@end diff --git a/BeeFramework/MVC/Controller/Extension/BeeMessage+HTTP.mm b/BeeFramework/MVC/Controller/Extension/BeeMessage+HTTP.mm new file mode 100644 index 0000000..4b225ba --- /dev/null +++ b/BeeFramework/MVC/Controller/Extension/BeeMessage+HTTP.mm @@ -0,0 +1,201 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// BeeMessage+HTTP.mm +// + +#import "Bee_Precompile.h" +#import "Bee_Log.h" +#import "BeeMessage+HTTP.h" + +#import + +#pragma mark - + +@interface BeeMessage(HTTPPrivate) +- (void)internalNotifyProgressUpdated; +@end + +#pragma mark - + +@implementation BeeMessage(HTTP) + +@dynamic requesting; +@dynamic request; +@dynamic response; +@dynamic responseString; + +- (BOOL)requesting +{ + return self.requestingURL; +} + +- (BeeRequest *)request +{ + NSArray * array = self.requests; + + for ( BeeRequest * req in array ) + { + if ( req.sending ) + { + return req; + } + } + + return nil; +} + +- (NSData *)response +{ + NSArray * array = self.requests; + + for ( BeeRequest * req in array ) + { + if ( req.succeed ) + { + return req.responseData; + } + } + + return nil; +} + +- (NSString *)responseString +{ + NSData * data = [self response]; + if ( data ) + { + return [[[NSString alloc] initWithBytes:[data bytes] length:[data length] encoding:NSUTF8StringEncoding] autorelease]; + } + + return nil; +} + +- (void)handleRequest:(BeeRequest *)request +{ + if ( request.sending ) + { + } + else if ( request.sendProgressed ) + { + [self internalNotifyProgressUpdated]; + } + else if ( request.recving ) + { + } + else if ( request.recvProgressed ) + { + [self internalNotifyProgressUpdated]; + } + else if ( request.succeed ) + { + [self changeState:BeeMessage.STATE_SUCCEED]; + } + else if ( request.failed ) + { + if ( self.timeout ) + { + self.errorDomain = BeeMessage.ERROR_DOMAIN_SERVER; + self.errorCode = BeeMessage.ERROR_CODE_TIMEOUT; + self.errorDesc = @"timeout"; + } + else + { + self.errorDomain = BeeMessage.ERROR_DOMAIN_NETWORK; + self.errorCode = request.errorCode; + self.errorDesc = nil; + } + + [self changeState:BeeMessage.STATE_FAILED]; + } + else if ( request.cancelled ) + { + [self changeState:BeeMessage.STATE_CANCELLED]; + } +} + +- (float)uploadProgress +{ + NSArray * array = self.requests; + + if ( array && array.count ) + { + float percent = 0.0f; + + for ( BeeRequest * req in array ) + { + unsigned long long sent = [req totalBytesSent]; + unsigned long long total = [req postLength]; + + CC( @"%@(%@), sent = %d, total = %d", self.message, [req.url absoluteString], sent, total ); + + if ( total ) + { + percent += (sent * 1.0f) / (total * 1.0f); + } + } + + return (percent / array.count); + } + else + { + return 0.0f; + } +} + +- (float)downloadProgress +{ + NSArray * array = self.requests; + + if ( array && array.count ) + { + float percent = 0.0f; + + for ( BeeRequest * req in array ) + { + unsigned long long recv = [req totalBytesRead]; + unsigned long long total = [req contentLength]; + + CC( @"%@(%@), recv = %d, total = %d", self.message, [req.url absoluteString], recv, total ); + + if ( total ) + { + percent += (recv * 1.0f) / (total * 1.0f); + } + } + + return (percent / array.count); + } + else + { + return 0.0f; + } +} + +@end diff --git a/BeeFramework/MVC/Controller/Extension/BeeMessage+JSON.h b/BeeFramework/MVC/Controller/Extension/BeeMessage+JSON.h new file mode 100644 index 0000000..8f6d561 --- /dev/null +++ b/BeeFramework/MVC/Controller/Extension/BeeMessage+JSON.h @@ -0,0 +1,52 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// BeeMessage+JSON.h +// + +#import "Bee_Precompile.h" +#import "Bee_Message.h" +#import "Bee_Network.h" + +#pragma mark - + +typedef BeeRequest * (^BeeMessageJSONRequestBlock)( NSString * url, id json ); + +#pragma mark - + +@interface BeeMessage(JSON) + +@property (nonatomic, readonly) BeeMessageJSONRequestBlock JSON_GET; +@property (nonatomic, readonly) BeeMessageJSONRequestBlock JSON_POST; + +@property (nonatomic, readonly) id responseJSON; +@property (nonatomic, readonly) NSDictionary * responseJSONDictionary; +@property (nonatomic, readonly) NSArray * responseJSONArray; + +@end diff --git a/BeeFramework/MVC/View/UIView+BeeBackground.m b/BeeFramework/MVC/Controller/Extension/BeeMessage+JSON.mm similarity index 51% rename from BeeFramework/MVC/View/UIView+BeeBackground.m rename to BeeFramework/MVC/Controller/Extension/BeeMessage+JSON.mm index 1105b74..6a9afe6 100644 --- a/BeeFramework/MVC/View/UIView+BeeBackground.m +++ b/BeeFramework/MVC/Controller/Extension/BeeMessage+JSON.mm @@ -27,85 +27,92 @@ // IN THE SOFTWARE. // // -// UIView+BeeBackground.m +// BeeMessage+JSON.h // #import "Bee_Precompile.h" -#import "Bee_UISignal.h" -#import "Bee_UIImageView.h" -#import "Bee_UILabel.h" -#import "UIView+BeeBackground.h" +#import "Bee_Network.h" +#import "BeeMessage+JSON.h" +#import "BeeMessage+HTTP.h" -#pragma mark - - -@interface BeeBackgroundImageView : BeeUIImageView -@end +#import "JSONKit.h" +#import #pragma mark - -@implementation BeeBackgroundImageView -@end +@implementation BeeMessage(JSON) -#pragma mark - +@dynamic JSON_GET; +@dynamic JSON_POST; +@dynamic responseJSON; +@dynamic responseJSONDictionary; +@dynamic responseJSONArray; -@implementation UIView(BeeBackground) +- (BeeMessageJSONRequestBlock)JSON_GET +{ + BeeMessageJSONRequestBlock block = ^ BeeRequest * ( NSString * url, id json ) + { + BeeRequest * req = self.HTTP_GET( url ); -@dynamic backgroundImageView; + if ( req && json ) + { + req.BODY( [json JSONData] ); + } -- (BeeUIImageView *)backgroundImageView -{ - return [self __backgroundImageView]; + return req; + }; + + return [[block copy] autorelease]; } -- (BeeBackgroundImageView *)__backgroundImageView +- (BeeMessageJSONRequestBlock)JSON_POST { - BeeBackgroundImageView * result = nil; - - for ( UIView * subView in self.subviews ) + BeeMessageJSONRequestBlock block = ^ BeeRequest * ( NSString * url, id json ) { - if ( [subView isKindOfClass:[BeeBackgroundImageView class]] ) + BeeRequest * req = self.HTTP_POST( url ); + + if ( req && json ) { - result = (BeeBackgroundImageView *)subView; - break; + req.BODY( [json JSONData] ); } - } - return result; + return req; + }; + + return [[block copy] autorelease]; } -- (void)setBackgroundImage:(UIImage *)image +- (id)responseJSON { - if ( image ) + NSData * data = self.response; + if ( data ) { - BeeBackgroundImageView * imageView = [self __backgroundImageView]; - if ( nil == imageView ) - { - imageView = [[[BeeBackgroundImageView alloc] initWithFrame:self.bounds] autorelease]; - [self addSubview:imageView]; - [self sendSubviewToBack:imageView]; - } - - imageView.image = image; - imageView.frame = self.bounds; - [imageView setNeedsDisplay]; + return [data objectFromJSONData]; } - else + + return nil; +} + +- (NSDictionary *)responseJSONDictionary +{ + id obj = self.responseJSON; + if ( obj && [obj isKindOfClass:[NSDictionary class]] ) { - BeeBackgroundImageView * imageView = [self __backgroundImageView]; - if ( imageView ) - { - [imageView removeFromSuperview]; - } + return (NSDictionary *)obj; } + + return nil; } -- (void)fitBackgroundFrame +- (NSArray *)responseJSONArray { - BeeBackgroundImageView * imageView = [self __backgroundImageView]; - if ( imageView ) + id obj = self.responseJSON; + if ( obj && [obj isKindOfClass:[NSArray class]] ) { - imageView.frame = self.bounds; + return (NSArray *)obj; } + + return nil; } @end diff --git a/BeeFramework/MVC/Controller/Extension/BeeMessage+XML.h b/BeeFramework/MVC/Controller/Extension/BeeMessage+XML.h new file mode 100644 index 0000000..2e63d7f --- /dev/null +++ b/BeeFramework/MVC/Controller/Extension/BeeMessage+XML.h @@ -0,0 +1,49 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// BeeMessage+XML.h +// + +#import "Bee_Precompile.h" +#import "Bee_Message.h" +#import "Bee_Network.h" + +#pragma mark - + +typedef BeeRequest * (^BeeMessageXMLRequestBlock)( NSString * url, id xml ); + +#pragma mark - + +@interface BeeMessage(XML) + +@property (nonatomic, readonly) BeeMessageXMLRequestBlock XML_GET; +@property (nonatomic, readonly) BeeMessageXMLRequestBlock XML_POST; +@property (nonatomic, readonly) id responseXML; + +@end diff --git a/BeeFramework/MVC/Controller/Extension/BeeMessage+XML.mm b/BeeFramework/MVC/Controller/Extension/BeeMessage+XML.mm new file mode 100644 index 0000000..bdd9a79 --- /dev/null +++ b/BeeFramework/MVC/Controller/Extension/BeeMessage+XML.mm @@ -0,0 +1,78 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// BeeMessage+XML.h +// + +#import "Bee_Precompile.h" +#import "Bee_Network.h" +#import "BeeMessage+XML.h" +#import "BeeMessage+HTTP.h" + +#import + +#pragma mark - + +@implementation BeeMessage(XML) + +- (BeeMessageXMLRequestBlock)XML_GET +{ + BeeMessageXMLRequestBlock block = ^ BeeRequest * ( NSString * url, id xml ) + { + // TODO: convert xml into string + return nil; + }; + + return [[block copy] autorelease]; +} + +- (BeeMessageXMLRequestBlock)XML_POST +{ + BeeMessageXMLRequestBlock block = ^ BeeRequest * ( NSString * url, id xml ) + { + // TODO: convert xml into string + return nil; + }; + + return [[block copy] autorelease]; +} + +- (id)responseXML +{ + NSData * data = self.response; + if ( data ) + { + // TODO: parse XML + return nil; + } + + return nil; +} + +@end diff --git a/BeeFramework/MVC/Controller/Extension/NSObject+BeeMessage.h b/BeeFramework/MVC/Controller/Extension/NSObject+BeeMessage.h new file mode 100644 index 0000000..34d8ded --- /dev/null +++ b/BeeFramework/MVC/Controller/Extension/NSObject+BeeMessage.h @@ -0,0 +1,56 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// NSObject+BeeMessage.h +// + +#import "Bee_Precompile.h" +#import "Bee_Message.h" + +#pragma mark - + +@interface NSObject(BeeMessage) + +@property (nonatomic, readonly) BeeMessageBlockN MSG; +@property (nonatomic, readonly) BeeMessageBlockN MSG_IF_NOT_SENDING; +@property (nonatomic, readonly) BeeMessageBlockN MSG_CANCEL_IF_SENDING; + +- (BOOL)sendingMessage:(NSString *)msg; +- (void)cancelMessage:(NSString *)msg; +- (void)cancelMessages; + +- (BeeMessage *)message:(NSString *)msg; +- (BeeMessage *)message:(NSString *)msg timeoutSeconds:(NSUInteger)seconds; + +- (BeeMessage *)sendMessage:(NSString *)msg; +- (BeeMessage *)sendMessage:(NSString *)msg timeoutSeconds:(NSUInteger)seconds; + +- (void)handleMessage:(BeeMessage *)msg; + +@end diff --git a/BeeFramework/MVC/Controller/Extension/NSObject+BeeMessage.mm b/BeeFramework/MVC/Controller/Extension/NSObject+BeeMessage.mm new file mode 100644 index 0000000..9b1ecf9 --- /dev/null +++ b/BeeFramework/MVC/Controller/Extension/NSObject+BeeMessage.mm @@ -0,0 +1,126 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_Message.h +// + +#import "Bee_Precompile.h" +#import "Bee_Message.h" +#import "Bee_MessageQueue.h" +#import "NSObject+BeeMessage.h" + +#import + +#pragma mark - + +@implementation NSObject(BeeMessage) + +@dynamic MSG; +@dynamic MSG_IF_NOT_SENDING; +@dynamic MSG_CANCEL_IF_SENDING; + +- (BeeMessageBlockN)MSG +{ + BeeMessageBlockN block = ^ BeeMessage * ( id first, ... ) + { + return [self sendMessage:(NSString *)first]; + }; + + return [[block copy] autorelease]; +} + +- (BeeMessageBlockN)MSG_IF_NOT_SENDING +{ + BeeMessageBlockN block = ^ BeeMessage * ( id first, ... ) + { + if ( [self sendingMessage:(NSString *)first] ) + { + return [BeeMessage message]; + } + else + { + return [self sendMessage:(NSString *)first]; + } + }; + + return [[block copy] autorelease]; +} + +- (BeeMessageBlockN)MSG_CANCEL_IF_SENDING +{ + BeeMessageBlockN block = ^ BeeMessage * ( id first, ... ) + { + [self cancelMessage:(NSString *)first]; + + return [self message:(NSString *)first]; + }; + + return [[block copy] autorelease]; +} + +- (BOOL)sendingMessage:(NSString *)msg +{ + return [[BeeMessageQueue sharedInstance] sending:msg byResponder:self]; +} + +- (void)cancelMessage:(NSString *)msg +{ + [[BeeMessageQueue sharedInstance] cancelMessage:msg byResponder:self]; +} + +- (void)cancelMessages +{ + [[BeeMessageQueue sharedInstance] cancelMessage:nil byResponder:self]; +} + +- (BeeMessage *)message:(NSString *)msg +{ + return [self message:msg timeoutSeconds:0]; +} + +- (BeeMessage *)message:(NSString *)msg timeoutSeconds:(NSUInteger)seconds +{ + return [BeeMessage message:msg responder:self timeoutSeconds:seconds]; +} + +- (BeeMessage *)sendMessage:(NSString *)msg +{ + return [self sendMessage:msg timeoutSeconds:0]; +} + +- (BeeMessage *)sendMessage:(NSString *)msg timeoutSeconds:(NSUInteger)seconds +{ + return [[BeeMessage message:msg responder:self timeoutSeconds:seconds] send]; +} + +- (void)handleMessage:(BeeMessage *)msg +{ +} + +@end diff --git a/BeeFramework/MVC/Bee_Model.h b/BeeFramework/MVC/Model/Bee_Model.h similarity index 87% rename from BeeFramework/MVC/Bee_Model.h rename to BeeFramework/MVC/Model/Bee_Model.h index 13731f8..642864a 100644 --- a/BeeFramework/MVC/Bee_Model.h +++ b/BeeFramework/MVC/Model/Bee_Model.h @@ -34,7 +34,15 @@ #pragma mark - -@interface BeeModel : NSObject +@protocol BeeSerializable +@required +- (void)serialize; // save into DB +- (void)unserialize; // load from DB +@end + +#pragma mark - + +@interface BeeModel : NSObject { NSString * _name; NSMutableArray * _observers; @@ -50,7 +58,7 @@ - (void)load; - (void)unload; -- (void)bind:(id)obj; -- (void)unbind:(id)obj; +- (void)addObserver:(id)obj; +- (void)removeObserver:(id)obj; @end diff --git a/BeeFramework/MVC/Bee_Model.m b/BeeFramework/MVC/Model/Bee_Model.m similarity index 85% rename from BeeFramework/MVC/Bee_Model.m rename to BeeFramework/MVC/Model/Bee_Model.m index 7cafdc8..7fb0328 100644 --- a/BeeFramework/MVC/Bee_Model.m +++ b/BeeFramework/MVC/Model/Bee_Model.m @@ -35,6 +35,7 @@ #import "Bee_Controller.h" #import "Bee_Network.h" #import "NSArray+BeeExtension.h" +#import "NSObject+BeeMessage.h" #import "JSONKit.h" @@ -103,10 +104,10 @@ - (void)initSelf { if ( nil == __models ) { - __models = [[NSMutableArray alloc] init]; + __models = [NSMutableArray nonRetainingArray]; } - [__models addObjectNoRetain:self]; + [__models addObject:self]; _name = [[[self class] description] retain]; _observers = [[NSMutableArray alloc] init]; @@ -114,27 +115,43 @@ - (void)initSelf - (void)load { - +// if ( [self respondsToSelector:@selector(unserialize)] ) +// { + [self unserialize]; +// } } - (void)unload { +// if ( [self respondsToSelector:@selector(serialize)] ) +// { + [self serialize]; +// } +} + +- (void)serialize +{ + +} + +- (void)unserialize +{ } -- (void)bind:(id)obj +- (void)addObserver:(id)obj { if ( [_observers containsObject:obj] ) return; - [_observers addObjectNoRetain:obj]; + [_observers addObject:obj]; } -- (void)unbind:(id)obj +- (void)removeObserver:(id)obj { if ( [_observers containsObject:obj] ) { - [_observers removeObjectNoRelease:obj]; + [_observers removeObject:obj]; } } @@ -144,12 +161,12 @@ - (void)dealloc [self cancelMessages]; [self cancelRequests]; - [_observers removeAllObjectsNoRelease]; + [_observers removeAllObjects]; [_observers release]; [_name release]; - [__models removeObjectNoRelease:self]; + [__models removeObject:self]; [super dealloc]; } diff --git a/BeeFramework/MVC/View/Bee_UIActionSheet.h b/BeeFramework/MVC/View/Bee_UIActionSheet.h index f13029f..37d9535 100644 --- a/BeeFramework/MVC/View/Bee_UIActionSheet.h +++ b/BeeFramework/MVC/View/Bee_UIActionSheet.h @@ -51,7 +51,9 @@ AS_SIGNAL( DID_DISMISS ) // 已经隐藏 @property (nonatomic, retain) NSObject * userData; + (BeeUIActionSheet *)spawn; ++ (BeeUIActionSheet *)spawn:(NSString * )tagString; +- (void)showInViewController:(UIViewController *)controller; // samw as presentForController: - (void)presentForController:(UIViewController *)controller; - (void)dismissAnimated:(BOOL)animated; diff --git a/BeeFramework/MVC/View/Bee_UIActionSheet.m b/BeeFramework/MVC/View/Bee_UIActionSheet.m index 20cae57..48ed78f 100644 --- a/BeeFramework/MVC/View/Bee_UIActionSheet.m +++ b/BeeFramework/MVC/View/Bee_UIActionSheet.m @@ -33,6 +33,8 @@ #import "Bee_Precompile.h" #import "Bee_UIActionSheet.h" #import "Bee_UISignal.h" +#import "UIView+BeeExtension.h" +#import "UIView+BeeUISignal.h" #pragma mark - @@ -51,6 +53,13 @@ + (BeeUIActionSheet *)spawn return [[[BeeUIActionSheet alloc] init] autorelease]; } ++ (BeeUIActionSheet *)spawn:(NSString * )tagString +{ + BeeUIActionSheet * view = [[[BeeUIActionSheet alloc] init] autorelease]; + view.tagString = tagString; + return view; +} + - (id)init { self = [super init]; @@ -68,13 +77,56 @@ - (id)init - (void)dealloc { [_userData release]; - + [_actions removeAllObjects]; [_actions release]; [super dealloc]; } +- (void)showFromToolbar:(UIToolbar *)view +{ + _parentView = view; + + [super showFromToolbar:view]; +} + +- (void)showFromTabBar:(UITabBar *)view +{ + _parentView = view; + + [super showFromTabBar:view]; +} + +- (void)showFromBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated +{ + if ( item.target && [item.target isKindOfClass:[UIView class]] ) + { + _parentView = item.target; + } + + [super showFromBarButtonItem:item animated:animated]; +} + +- (void)showFromRect:(CGRect)rect inView:(UIView *)view animated:(BOOL)animated +{ + _parentView = view; + + [super showFromRect:rect inView:view animated:animated]; +} + +- (void)showInView:(UIView *)view +{ + _parentView = view; + + [super showInView:view]; +} + +- (void)showInViewController:(UIViewController *)controller +{ + [self presentForController:controller]; +} + - (void)presentForController:(UIViewController *)controller { _parentView = controller.view; diff --git a/BeeFramework/MVC/View/Bee_UIActivityIndicatorView.h b/BeeFramework/MVC/View/Bee_UIActivityIndicatorView.h index 9d95c90..313ab06 100644 --- a/BeeFramework/MVC/View/Bee_UIActivityIndicatorView.h +++ b/BeeFramework/MVC/View/Bee_UIActivityIndicatorView.h @@ -43,5 +43,6 @@ AS_SIGNAL( WILL_STOP ) // 动画将要停止 AS_SIGNAL( DID_STOP ) // 动画已经停止 + (BeeUIActivityIndicatorView *)spawn; ++ (BeeUIActivityIndicatorView *)spawn:(NSString *)tagString; @end diff --git a/BeeFramework/MVC/View/Bee_UIActivityIndicatorView.m b/BeeFramework/MVC/View/Bee_UIActivityIndicatorView.m index 9d1b238..a794a64 100644 --- a/BeeFramework/MVC/View/Bee_UIActivityIndicatorView.m +++ b/BeeFramework/MVC/View/Bee_UIActivityIndicatorView.m @@ -34,6 +34,8 @@ #import "Bee_UIActivityIndicatorView.h" #import "Bee_UISignal.h" #import "Bee_SystemInfo.h" +#import "UIView+BeeExtension.h" +#import "UIView+BeeUISignal.h" #pragma mark - @@ -53,6 +55,13 @@ + (BeeUIActivityIndicatorView *)spawn return [[[BeeUIActivityIndicatorView alloc] init] autorelease]; } ++ (BeeUIActivityIndicatorView *)spawn:(NSString *)tagString +{ + BeeUIActivityIndicatorView * view = [[[BeeUIActivityIndicatorView alloc] init] autorelease]; + view.tagString = tagString; + return view; +} + - (id)init { self = [super initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite]; diff --git a/BeeFramework/MVC/View/Bee_UIAlertView.h b/BeeFramework/MVC/View/Bee_UIAlertView.h index d9b21e4..eec474f 100644 --- a/BeeFramework/MVC/View/Bee_UIAlertView.h +++ b/BeeFramework/MVC/View/Bee_UIAlertView.h @@ -50,9 +50,14 @@ AS_SIGNAL( DID_DISMISS ) // 已经隐藏 @property (nonatomic, assign) UIView * parentView; @property (nonatomic, retain) NSObject * userData; -+ (BeeUIAlertView *)spawn; + (BeeUIAlertView *)showMessage:(NSString *)message cancelTitle:(NSString *)title; ++ (BeeUIAlertView *)spawn; ++ (BeeUIAlertView *)spawn:(NSString *)tagString; + +- (void)showInView:(UIView *)view; +- (void)showInViewController:(UIViewController *)controller; // same as presentForController: + - (void)presentForController:(UIViewController *)controller; - (void)dismissAnimated:(BOOL)animated; diff --git a/BeeFramework/MVC/View/Bee_UIAlertView.m b/BeeFramework/MVC/View/Bee_UIAlertView.m index 8f0602e..fce3b0a 100644 --- a/BeeFramework/MVC/View/Bee_UIAlertView.m +++ b/BeeFramework/MVC/View/Bee_UIAlertView.m @@ -33,6 +33,9 @@ #import "Bee_Precompile.h" #import "Bee_UIAlertView.h" #import "Bee_UISignal.h" +#import "UIView+BeeExtension.h" +#import "UIView+BeeUISignal.h" +#import "UIView+BeeUISignal.h" #pragma mark - @@ -46,20 +49,25 @@ @implementation BeeUIAlertView @synthesize parentView = _parentView; @synthesize userData = _userData; ++ (BeeUIAlertView *)showMessage:(NSString *)message cancelTitle:(NSString *)title +{ + BeeUIAlertView * alert = [BeeUIAlertView spawn]; + [alert setMessage:message]; + [alert addCancelTitle:title]; + [alert show]; + return alert; +} + + (BeeUIAlertView *)spawn { return [[[BeeUIAlertView alloc] init] autorelease]; } -+ (BeeUIAlertView *)showMessage:(NSString *)message cancelTitle:(NSString *)cancel ++ (BeeUIAlertView *)spawn:(NSString *)tagString { - BeeUIAlertView * alert = [[[BeeUIAlertView alloc] initWithTitle:nil - message:message - delegate:self - cancelButtonTitle:cancel - otherButtonTitles:nil] autorelease]; - [alert show]; - return alert; + BeeUIAlertView * view = [[[BeeUIAlertView alloc] init] autorelease]; + view.tagString = tagString; + return view; } - (id)init @@ -85,6 +93,20 @@ - (void)dealloc [super dealloc]; } +- (void)showInView:(UIView *)view +{ + _parentView = view; + + [self show]; +} + +- (void)showInViewController:(UIViewController *)controller +{ + _parentView = controller.view; + + [self show]; +} + - (void)presentForController:(UIViewController *)controller { _parentView = controller.view; diff --git a/BeeFramework/MVC/View/Bee_UIButton.h b/BeeFramework/MVC/View/Bee_UIButton.h index c7f499a..9a8b33e 100644 --- a/BeeFramework/MVC/View/Bee_UIButton.h +++ b/BeeFramework/MVC/View/Bee_UIButton.h @@ -35,8 +35,6 @@ #pragma mark - -//typedef void (^BeeButtonBlock)( UIView * view ); - @class BeeUIButton; @interface BeeUIButtonState : NSObject @@ -62,12 +60,6 @@ NSMutableArray * _actions; UILabel * _label; UIEdgeInsets _insets; - -// BeeButtonBlock _touchDown; -// BeeButtonBlock _touchDownRepeat; -// BeeButtonBlock _touchUpInside; -// BeeButtonBlock _touchUpOutside; -// BeeButtonBlock _touchUpCancel; BeeUIButtonState * _stateNormal; BeeUIButtonState * _stateHighlighted; @@ -92,6 +84,7 @@ AS_SIGNAL( TOUCH_UP_CANCEL ) // 撤销 @property (nonatomic, readonly) BeeUIButtonState * stateSelected; + (BeeUIButton *)spawn; ++ (BeeUIButton *)spawn:(NSString *)tagString; - (void)addSignal:(NSString *)signal forControlEvents:(UIControlEvents)controlEvents; - (void)addSignal:(NSString *)signal forControlEvents:(UIControlEvents)controlEvents object:(NSObject *)object; diff --git a/BeeFramework/MVC/View/Bee_UIButton.m b/BeeFramework/MVC/View/Bee_UIButton.m index 93a2791..d0a395e 100644 --- a/BeeFramework/MVC/View/Bee_UIButton.m +++ b/BeeFramework/MVC/View/Bee_UIButton.m @@ -33,7 +33,9 @@ #import "Bee_Precompile.h" #import "Bee_UIButton.h" #import "Bee_UISignal.h" -#import "UIView+BeeQuery.h" +#import "UIView+BeeExtension.h" +#import "UIView+BeeUISignal.h" +#import "UIView+BeeUISignal.h" #pragma mark - @@ -118,6 +120,13 @@ + (BeeUIButton *)spawn return [[[BeeUIButton alloc] init] autorelease]; } ++ (BeeUIButton *)spawn:(NSString *)tagString +{ + BeeUIButton * view = [[[BeeUIButton alloc] init] autorelease]; + view.tagString = tagString; + return view; +} + - (id)init { self = [super init]; @@ -285,7 +294,7 @@ - (BeeUIButtonState *)stateSelected { _stateSelected = [[BeeUIButtonState alloc] init]; _stateSelected.button = self; - _stateSelected.state = UIControlStateDisabled; + _stateSelected.state = UIControlStateSelected; } return _stateSelected; diff --git a/BeeFramework/MVC/View/Bee_UIDatePicker.h b/BeeFramework/MVC/View/Bee_UIDatePicker.h index fe3d87b..0af80e9 100644 --- a/BeeFramework/MVC/View/Bee_UIDatePicker.h +++ b/BeeFramework/MVC/View/Bee_UIDatePicker.h @@ -37,7 +37,6 @@ @interface BeeUIDatePicker : UIActionSheet { - NSDate * _date; UIDatePicker * _datePicker; UIView * _parentView; NSObject * _userData; @@ -50,12 +49,26 @@ AS_SIGNAL( DID_DISMISS ) // 已经隐藏 AS_SIGNAL( CHANGED ) // 日期改变 AS_SIGNAL( CONFIRMED ) // 确认 -@property (nonatomic, retain) NSDate * date; -@property (nonatomic, retain) NSObject * userData; -@property (nonatomic, assign) UIView * parentView; +@property (nonatomic, retain) NSObject * userData; +@property (nonatomic, assign) UIView * parentView; + +@property (nonatomic, retain) NSDate * date; +@property (nonatomic, assign) UIDatePickerMode datePickerMode; +@property (nonatomic, assign) NSLocale * locale; +@property (nonatomic, assign) NSCalendar * calendar; +@property (nonatomic, assign) NSTimeZone * timeZone; +@property (nonatomic, assign) NSDate * minimumDate; +@property (nonatomic, assign) NSDate * maximumDate; +@property (nonatomic, assign) NSTimeInterval countDownDuration; +@property (nonatomic, assign) NSInteger minuteInterval; + (BeeUIDatePicker *)spawn; ++ (BeeUIDatePicker *)spawn:(NSString *)tagString; +- (void)showInViewController:(UIViewController *)controller; // samw as presentForController: - (void)presentForController:(UIViewController *)controller; +- (void)dismissAnimated:(BOOL)animated; + +- (void)setDate:(NSDate *)date animated:(BOOL)animated; @end diff --git a/BeeFramework/MVC/View/Bee_UIDatePicker.m b/BeeFramework/MVC/View/Bee_UIDatePicker.m index 318667f..e0c28c1 100644 --- a/BeeFramework/MVC/View/Bee_UIDatePicker.m +++ b/BeeFramework/MVC/View/Bee_UIDatePicker.m @@ -33,9 +33,13 @@ #import "Bee_Precompile.h" #import "Bee_UIDatePicker.h" #import "Bee_UISignal.h" -#import "UIView+BeeQuery.h" +#import "UIView+BeeExtension.h" +#import "UIView+BeeUISignal.h" + +#pragma mark - @interface BeeUIDatePicker(Private) +- (void)initSelf; - (void)didDateChanged; @end @@ -48,26 +52,55 @@ @implementation BeeUIDatePicker DEF_SIGNAL( CHANGED ) DEF_SIGNAL( CONFIRMED ) -@synthesize date = _date; @synthesize userData = _userData; @synthesize parentView = _parentView; +@dynamic date; +@dynamic datePickerMode; +@dynamic locale; +@dynamic calendar; +@dynamic timeZone; +@dynamic minimumDate; +@dynamic maximumDate; +@dynamic countDownDuration; +@dynamic minuteInterval; + + (BeeUIDatePicker *)spawn { return [[[BeeUIDatePicker alloc] init] autorelease]; } ++ (BeeUIDatePicker *)spawn:(NSString *)tagString +{ + BeeUIDatePicker * view = [[[BeeUIDatePicker alloc] init] autorelease]; + view.tagString = tagString; + return view; +} + +- (void)initSelf +{ + self.delegate = self; + self.date = [NSDate date]; + self.title = @"\n\n\n\\n\n\n\\n\n\n\n\n\n\n\n"; + self.actionSheetStyle = UIActionSheetStyleBlackTranslucent; +// self.actionSheetStyle = UIActionSheetStyleDefault; + self.cancelButtonIndex = [self addButtonWithTitle:@"确定"]; + + _datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 0, 320, 200)]; + _datePicker.date = [NSDate date]; + _datePicker.datePickerMode = UIDatePickerModeDate; + _datePicker.calendar = [NSCalendar currentCalendar]; + _datePicker.maximumDate = [NSDate date]; + [_datePicker addTarget:self action:@selector(didDateChanged) forControlEvents:UIControlEventValueChanged]; + [self addSubview:_datePicker]; +} + - (id)init { self = [super init]; if ( self ) { - self.delegate = self; - self.date = [NSDate date]; - self.title = @"\n\n\n\\n\n\n\\n\n\n\n\n\n\n\n"; - self.actionSheetStyle = UIActionSheetStyleBlackTranslucent; -// self.actionSheetStyle = UIActionSheetStyleDefault; - self.cancelButtonIndex = [self addButtonWithTitle:@"确定"]; + [self initSelf]; } return self; } @@ -76,12 +109,149 @@ - (void)dealloc { SAFE_RELEASE_SUBVIEW( _datePicker ); - [_date release]; [_userData release]; [super dealloc]; } +- (void)setDate:(NSDate *)date +{ + _datePicker.date = date; +} + +- (void)setDate:(NSDate *)date animated:(BOOL)animated +{ + [_datePicker setDate:date animated:animated]; +} + +- (NSDate *)date +{ + return _datePicker.date; +} + +- (void)setDatePickerMode:(UIDatePickerMode)datePickerMode +{ + _datePicker.datePickerMode = datePickerMode; +} + +- (UIDatePickerMode)datePickerMode +{ + return _datePicker.datePickerMode; +} + +- (void)setLocale:(NSLocale *)locale +{ + _datePicker.locale = locale; +} + +- (NSLocale *)locale +{ + return _datePicker.locale; +} + +- (void)setCalendar:(NSCalendar *)calendar +{ + _datePicker.calendar = calendar; +} + +- (NSCalendar *)calendar +{ + return _datePicker.calendar; +} + +- (void)setTimeZone:(NSTimeZone *)timeZone +{ + _datePicker.timeZone = timeZone; +} + +- (NSTimeZone *)timeZone +{ + return _datePicker.timeZone; +} + +- (void)setMinimumDate:(NSDate *)minimumDate +{ + _datePicker.minimumDate = minimumDate; +} + +- (NSDate *)minimumDate +{ + return _datePicker.minimumDate; +} + +- (void)setMaximumDate:(NSDate *)maximumDate +{ + _datePicker.maximumDate = maximumDate; +} + +- (NSDate *)maximumDate +{ + return _datePicker.maximumDate; +} + +- (void)setCountDownDuration:(NSTimeInterval)countDownDuration +{ + _datePicker.countDownDuration = countDownDuration; +} + +- (NSTimeInterval)countDownDuration +{ + return _datePicker.countDownDuration; +} + +- (void)setMinuteInterval:(NSInteger)minuteInterval +{ + _datePicker.minuteInterval = minuteInterval; +} + +- (NSInteger)minuteInterval +{ + return _datePicker.minuteInterval; +} + +- (void)showFromToolbar:(UIToolbar *)view +{ + _parentView = view; + + [self showInView:view]; +} + +- (void)showFromTabBar:(UITabBar *)view +{ + _parentView = view; + + [self showInView:view]; +} + +- (void)showFromBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated +{ + if ( item.target && [item.target isKindOfClass:[UIView class]] ) + { + _parentView = item.target; + } + + [super showFromBarButtonItem:item animated:animated]; +} + +- (void)showFromRect:(CGRect)rect inView:(UIView *)view animated:(BOOL)animated +{ + _parentView = view; + + [super showFromRect:rect inView:view animated:animated]; +} + +- (void)showInView:(UIView *)view +{ + _parentView = view; + + [super showInView:view]; +} + +- (void)showInViewController:(UIViewController *)controller +{ + [self presentForController:controller]; +} + - (void)presentForController:(UIViewController *)controller { _parentView = controller.view; @@ -89,6 +259,11 @@ - (void)presentForController:(UIViewController *)controller [self showInView:controller.view]; } +- (void)dismissAnimated:(BOOL)animated +{ + [self dismissWithClickedButtonIndex:self.cancelButtonIndex animated:animated]; +} + #pragma mark - #pragma mark UIActionSheetDelegate @@ -118,17 +293,6 @@ - (void)actionSheetCancel:(UIActionSheet *)actionSheet // before animation and showing view - (void)willPresentActionSheet:(UIActionSheet *)actionSheet { - if ( nil == _datePicker ) - { - _datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 0, 320, 200)]; - _datePicker.date = _date ? _date : [NSDate dateWithTimeIntervalSince1970:0]; - _datePicker.datePickerMode = UIDatePickerModeDate; - _datePicker.calendar = [NSCalendar currentCalendar]; - _datePicker.maximumDate = [NSDate date]; - [_datePicker addTarget:self action:@selector(didDateChanged) forControlEvents:UIControlEventValueChanged]; - [self addSubview:_datePicker]; - } - if ( _parentView ) { [_parentView sendUISignal:BeeUIDatePicker.WILL_PRESENT withObject:nil from:self]; diff --git a/BeeFramework/MVC/View/Bee_UIGridCell.h b/BeeFramework/MVC/View/Bee_UIGridCell.h index 6126db5..4bbda45 100644 --- a/BeeFramework/MVC/View/Bee_UIGridCell.h +++ b/BeeFramework/MVC/View/Bee_UIGridCell.h @@ -37,49 +37,36 @@ @class BeeUIGridCell; -#pragma mark - +@interface NSObject(BeeUILayout) + ++ (CGSize)sizeInBound:(CGSize)bound forData:(NSObject *)data; +- (void)layoutInBound:(CGSize)bound forCell:(BeeUIGridCell *)cell; -@interface NSObject(BeeUIGridCell) -+ (CGSize)cellSize:(NSObject *)data bound:(CGSize)bound; -- (void)cellLayout:(BeeUIGridCell *)cell bound:(CGSize)bound; @end +#pragma mark - + @interface BeeUIGridCell : UIView { - BOOL _autoLayout; - NSObject * _cellData; - NSString * _category; - NSObject * _layout; - NSMutableArray * _subCells; - BOOL _zoomsTouchWhenHighlighted; + NSObject * _cellData; + NSObject * _cellLayout; } -@property (nonatomic, assign) BOOL autoLayout; -@property (nonatomic, retain) NSObject * cellData; -@property (nonatomic, retain) NSString * category; -@property (nonatomic, assign) NSObject * layout; -@property (nonatomic, retain) NSMutableArray * subCells; -@property (nonatomic, assign) BOOL zoomsTouchWhenHighlighted; -@property (nonatomic, readonly) BeeUIGridCell * supercell; - -+ (BeeUIGridCell *)spawn; +@property (nonatomic, retain) NSObject * cellData; +@property (nonatomic, assign) NSObject * cellLayout; -- (void)bindData:(NSObject *)data; -- (void)clearData; +@property (nonatomic, readonly) NSArray * childCells; +@property (nonatomic, readonly) BeeUIGridCell * superCell; -- (NSMutableArray *)subCellsIncludeCategory:(NSString *)cate; -- (NSMutableArray *)subCellsExcludeCategory:(NSString *)cate; +- (void)load; +- (void)unload; -- (void)addSubcell:(BeeUIGridCell *)cell; -- (void)removeSubcell:(BeeUIGridCell *)cell; -- (void)removeAllSubcells; -- (void)layoutAllSubcells; -- (BeeUIGridCell *)hitTestSubCells:(CGPoint)point; +- (void)layoutSubcells; -- (void)beginLayout; -- (void)commitLayout; +- (void)dataWillChange; +- (void)dataDidChanged; -- (void)load; -- (void)unload; +- (void)layoutWillBegin; +- (void)layoutDidFinish; @end diff --git a/BeeFramework/MVC/View/Bee_UIGridCell.m b/BeeFramework/MVC/View/Bee_UIGridCell.m index 0312b3d..0122e08 100644 --- a/BeeFramework/MVC/View/Bee_UIGridCell.m +++ b/BeeFramework/MVC/View/Bee_UIGridCell.m @@ -31,21 +31,21 @@ // #import "Bee_Precompile.h" -#import "Bee_UIGridCell.h" #import "Bee_UISignal.h" +#import "Bee_UIGridCell.h" +#import "UIView+BeeExtension.h" #pragma mark - -@implementation NSObject(BeeUIGridCell) +@implementation NSObject(BeeUILayout) -+ (CGSize)cellSize:(NSObject *)data bound:(CGSize)bound ++ (CGSize)sizeInBound:(CGSize)bound forData:(NSObject *)data { return bound; } -- (void)cellLayout:(BeeUIGridCell *)cell bound:(CGSize)bound +- (void)layoutInBound:(CGSize)bound forCell:(BeeUIGridCell *)cell { - } @end @@ -58,16 +58,21 @@ - (void)initSelf; @implementation BeeUIGridCell -@synthesize autoLayout = _autoLayout; -@synthesize cellData = _cellData; -@synthesize category = _category; -@synthesize layout = _layout; -@synthesize subCells = _subCells; -@synthesize zoomsTouchWhenHighlighted = _zoomsTouchWhenHighlighted; +@dynamic cellData; +@dynamic cellLayout; + +@dynamic childCells; +@dynamic superCell; -+ (BeeUIGridCell *)spawn +- (void)initSelf { - return [[[BeeUIGridCell alloc] init] autorelease]; + self.backgroundColor = [UIColor clearColor]; + self.alpha = 1.0f; + self.layer.masksToBounds = YES; + self.layer.opaque = YES; + + _cellData = nil; + _cellLayout = self; } - (id)init @@ -88,23 +93,19 @@ - (id)initWithFrame:(CGRect)frame { [self initSelf]; [self load]; - - [self layoutAllSubcells]; + + [self setNeedsLayout]; } return self; } -- (void)initSelf +- (void)dealloc { - self.backgroundColor = [UIColor clearColor]; - self.alpha = 1.0f; - self.layer.masksToBounds = YES; - self.layer.opaque = YES; - - _layout = self; - _autoLayout = YES; - _subCells = [[NSMutableArray alloc] init]; - _zoomsTouchWhenHighlighted = NO; + [self unload]; + + [_cellData release]; + + [super dealloc]; } - (void)load @@ -115,90 +116,31 @@ - (void)unload { } -- (BeeUIGridCell *)supercell -{ - if ( [self.superview isKindOfClass:[BeeUIGridCell class]] ) - { - return (BeeUIGridCell *)self.superview; - } - else - { - return nil; - } -} - -- (NSString *)description -{ - return _category ? _category : @"unknown"; -} - -- (NSMutableArray *)subCellsIncludeCategory:(NSString *)cate -{ - if ( 0 == [_subCells count] ) - { - return nil; - } - else - { - NSMutableArray * array = [[NSMutableArray alloc] init]; - for ( BeeUIGridCell * cell in _subCells ) - { - if ( YES == [cell.category isEqualToString:cate] ) - { - [array addObject:cell]; - } - } - return [array autorelease]; - } -} - -- (NSMutableArray *)subCellsExcludeCategory:(NSString *)cate +- (NSArray *)childCells { - if ( 0 == [_subCells count] ) - { - return nil; - } - else + NSMutableArray * array = [NSMutableArray array]; + + for ( UIView * subview in self.subviews ) { - NSMutableArray * array = [[NSMutableArray alloc] init]; - for ( BeeUIGridCell * cell in _subCells ) + if ( [subview isKindOfClass:[BeeUIGridCell class]] ) { - if ( NO == [cell.category isEqualToString:cate] ) - { - [array addObject:cell]; - } + [array addObject:subview]; } - return [array autorelease]; } -} -- (void)addSubcell:(BeeUIGridCell *)cell -{ - if ( NO == [_subCells containsObject:cell] ) - { - [_subCells addObject:cell]; - [self addSubview:cell]; - } + return array; } -- (void)removeSubcell:(BeeUIGridCell *)cell +- (BeeUIGridCell *)superCell { - if ( YES == [_subCells containsObject:cell] ) + if ( [self.superview isKindOfClass:[BeeUIGridCell class]] ) { - [_subCells removeObject:cell]; - [cell removeFromSuperview]; - [cell release]; + return (BeeUIGridCell *)self.superview; } -} - -- (void)removeAllSubcells -{ - for ( BeeUIGridCell * cell in _subCells ) + else { - [cell removeFromSuperview]; + return nil; } - - [_subCells removeAllObjects]; } - (void)setFrame:(CGRect)rc @@ -207,10 +149,7 @@ - (void)setFrame:(CGRect)rc { [super setFrame:rc]; - if ( _autoLayout ) - { - [self layoutAllSubcells]; - } + [self layoutSubcells]; } else { @@ -224,10 +163,7 @@ - (void)setCenter:(CGPoint)pt { [super setCenter:pt]; - if ( _autoLayout ) - { - [self layoutAllSubcells]; - } + [self layoutSubcells]; } else { @@ -235,136 +171,85 @@ - (void)setCenter:(CGPoint)pt } } -- (void)layoutAllSubcells +- (void)layoutSubcells { if ( CGSizeEqualToSize(self.bounds.size, CGSizeZero) ) return; - - if ( _layout && [_layout respondsToSelector:@selector(cellLayout:bound:)] ) + + [self layoutWillBegin]; + + if ( _cellLayout && [_cellLayout respondsToSelector:@selector(layoutInBound:forCell:)] ) { - [_layout cellLayout:self bound:self.bounds.size]; + [_cellLayout layoutInBound:self.bounds.size forCell:self]; +// [_cellLayout cellLayout:self bound:self.bounds.size]; } - for ( BeeUIGridCell * cell in _subCells ) + for ( UIView * subview in self.subviews ) { - if ( cell && [cell respondsToSelector:@selector(layoutAllSubcells)] ) + if ( [subview isKindOfClass:[BeeUIGridCell class]] ) { - [cell layoutAllSubcells]; + [(BeeUIGridCell *)subview layoutSubcells]; } } + + [self layoutDidFinish]; } -- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event +- (NSObject *)cellData { - [super touchesBegan:touches withEvent:event]; - - if ( _zoomsTouchWhenHighlighted ) - { - [UIView beginAnimations:nil context:nil]; - [UIView setAnimationDuration:0.1f]; - [UIView setAnimationCurve:UIViewAnimationCurveLinear]; - [UIView setAnimationBeginsFromCurrentState:YES]; - - CATransform3D transform = CATransform3DIdentity; - transform.m34 = -(1.0f / 2500.0f); - transform = CATransform3DTranslate( transform, 0.0f, 0.0f, -250.0f ); - self.layer.transform = transform; - - [UIView commitAnimations]; - } + return _cellData; } -- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event +- (void)setCellData:(NSObject *)data { - [super touchesEnded:touches withEvent:event]; - - if ( _zoomsTouchWhenHighlighted ) + [self dataWillChange]; + + if ( _cellData != data ) { - [UIView beginAnimations:nil context:nil]; - [UIView setAnimationDuration:0.1f]; - [UIView setAnimationCurve:UIViewAnimationCurveLinear]; - [UIView setAnimationBeginsFromCurrentState:YES]; - - self.layer.transform = CATransform3DIdentity; - - [UIView commitAnimations]; + [_cellData release]; + _cellData = [data retain]; } -} -- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event -{ - [super touchesCancelled:touches withEvent:event]; - - if ( _zoomsTouchWhenHighlighted ) + [self dataDidChanged]; + + if ( _cellLayout ) { - [UIView beginAnimations:nil context:nil]; - [UIView setAnimationDuration:0.1f]; - [UIView setAnimationCurve:UIViewAnimationCurveLinear]; - [UIView setAnimationBeginsFromCurrentState:YES]; - - self.layer.transform = CATransform3DIdentity; - - [UIView commitAnimations]; + [self layoutSubcells]; } } -- (void)clearData +- (NSObject *)cellLayout { - self.cellData = nil; + return _cellLayout; } -- (void)bindData:(NSObject *)data +- (void)setCellLayout:(NSObject *)layout { - if ( nil == data ) + if ( _cellLayout != layout ) { - [self clearData]; - [self layoutAllSubcells]; - return; - } - -// if ( data != self.cellData ) -// { - self.cellData = data; - [self layoutAllSubcells]; -// } -} + _cellLayout = layout; -- (BeeUIGridCell *)hitTestSubCells:(CGPoint)point -{ - for ( BeeUIGridCell * cell in _subCells ) - { - if ( CGRectContainsPoint(cell.frame, point) ) + if ( _cellLayout ) { - return cell; + [self layoutSubcells]; } } - - return nil; } -- (void)beginLayout +- (void)dataWillChange { - _autoLayout = NO; } -- (void)commitLayout +- (void)dataDidChanged { - _autoLayout = YES; - - [self layoutAllSubcells]; } -- (void)dealloc +- (void)layoutWillBegin { - [self unload]; - [self removeAllSubcells]; - - [_cellData release]; - [_category release]; - [_subCells release]; -// [_layout release]; +} - [super dealloc]; +- (void)layoutDidFinish +{ } @end diff --git a/BeeFramework/MVC/View/Bee_UIImageView.h b/BeeFramework/MVC/View/Bee_UIImageView.h index ee393f6..fbbed0e 100644 --- a/BeeFramework/MVC/View/Bee_UIImageView.h +++ b/BeeFramework/MVC/View/Bee_UIImageView.h @@ -37,6 +37,11 @@ #pragma mark - +@class BeeUIImageView; +@class BeeUIActivityIndicatorView; + +#pragma mark - + @interface BeeImageCache : NSObject { BeeMemoryCache * _memoryCache; @@ -57,8 +62,6 @@ AS_SINGLETON( BeeImageCache ) #pragma mark - -@class BeeUIActivityIndicatorView; - @interface BeeUIImageView : UIImageView { BOOL _gray; @@ -86,6 +89,7 @@ AS_SIGNAL( LOAD_CANCELLED ) // 加载取消 @property (nonatomic, assign) NSString * resource; + (BeeUIImageView *)spawn; ++ (BeeUIImageView *)spawn:(NSString *)tagString; - (void)GET:(NSString *)url useCache:(BOOL)useCache; - (void)GET:(NSString *)url useCache:(BOOL)useCache placeHolder:(UIImage *)defaultImage; diff --git a/BeeFramework/MVC/View/Bee_UIImageView.m b/BeeFramework/MVC/View/Bee_UIImageView.m index eacc113..363e3f7 100644 --- a/BeeFramework/MVC/View/Bee_UIImageView.m +++ b/BeeFramework/MVC/View/Bee_UIImageView.m @@ -41,7 +41,8 @@ #import "NSString+BeeExtension.h" #import "UIImage+BeeExtension.h" -#import "UIView+BeeQuery.h" +#import "UIView+BeeExtension.h" +#import "UIView+BeeUISignal.h" #pragma mark - @@ -178,6 +179,13 @@ + (BeeUIImageView *)spawn return [[[BeeUIImageView alloc] initWithImage:nil] autorelease]; } ++ (BeeUIImageView *)spawn:(NSString *)tagString +{ + BeeUIImageView * view = [[[BeeUIImageView alloc] init] autorelease]; + view.tagString = tagString; + return view; +} + - (id)init { self = [super init]; @@ -280,7 +288,7 @@ - (void)GET:(NSString *)string useCache:(BOOL)useCache placeHolder:(UIImage *)de [self cancelRequests]; PERF_ENTER_(5) - [self GET:string]; + self.HTTP_GET( string ); PERF_LEAVE } diff --git a/BeeFramework/MVC/View/Bee_UIKeyboard.m b/BeeFramework/MVC/View/Bee_UIKeyboard.m index 6051397..0f98cb6 100644 --- a/BeeFramework/MVC/View/Bee_UIKeyboard.m +++ b/BeeFramework/MVC/View/Bee_UIKeyboard.m @@ -210,7 +210,7 @@ - (void)updateAccessorAnimated:(BOOL)animated { if ( nil == _accessor ) return; - + if ( animated ) { [UIView beginAnimations:nil context:NULL]; diff --git a/BeeFramework/MVC/View/Bee_UILabel.h b/BeeFramework/MVC/View/Bee_UILabel.h index 34cf94d..70b0cd3 100644 --- a/BeeFramework/MVC/View/Bee_UILabel.h +++ b/BeeFramework/MVC/View/Bee_UILabel.h @@ -37,5 +37,6 @@ @interface BeeUILabel : UILabel + (BeeUILabel *)spawn; ++ (BeeUILabel *)spawn:(NSString *)tagString; @end diff --git a/BeeFramework/MVC/View/Bee_UILabel.m b/BeeFramework/MVC/View/Bee_UILabel.m index 6a77a7e..a88cf32 100644 --- a/BeeFramework/MVC/View/Bee_UILabel.m +++ b/BeeFramework/MVC/View/Bee_UILabel.m @@ -32,6 +32,7 @@ #import "Bee_Precompile.h" #import "Bee_UILabel.h" +#import "UIView+BeeExtension.h" #import "UIFont+BeeExtension.h" #pragma mark - @@ -47,6 +48,13 @@ + (BeeUILabel *)spawn return [[[BeeUILabel alloc] initWithFrame:CGRectZero] autorelease]; } ++ (BeeUILabel *)spawn:(NSString *)tagString +{ + BeeUILabel * view = [[[BeeUILabel alloc] init] autorelease]; + view.tagString = tagString; + return view; +} + - (id)init { self = [super initWithFrame:CGRectZero]; diff --git a/BeeFramework/MVC/View/Bee_UIPageControl.h b/BeeFramework/MVC/View/Bee_UIPageControl.h index 9031449..bb13fc5 100644 --- a/BeeFramework/MVC/View/Bee_UIPageControl.h +++ b/BeeFramework/MVC/View/Bee_UIPageControl.h @@ -47,5 +47,8 @@ @property (nonatomic, assign) CGSize dotSize; + (BeeUIPageControl *)spawn; ++ (BeeUIPageControl *)spawn:(NSString *)tagString; + +- (void)updateDotImages; @end diff --git a/BeeFramework/MVC/View/Bee_UIPageControl.m b/BeeFramework/MVC/View/Bee_UIPageControl.m index b3c9148..a6408e3 100644 --- a/BeeFramework/MVC/View/Bee_UIPageControl.m +++ b/BeeFramework/MVC/View/Bee_UIPageControl.m @@ -34,6 +34,7 @@ #import "Bee_UIPageControl.h" #import "Bee_UISignal.h" #import "Bee_SystemInfo.h" +#import "UIView+BeeExtension.h" #pragma mark - @@ -53,6 +54,13 @@ + (BeeUIPageControl *)spawn return [[[BeeUIPageControl alloc] init] autorelease]; } ++ (BeeUIPageControl *)spawn:(NSString *)tagString +{ + BeeUIPageControl * view = [[[BeeUIPageControl alloc] init] autorelease]; + view.tagString = tagString; + return view; +} + - (id)init { self = [super initWithFrame:CGRectZero]; diff --git a/BeeFramework/MVC/View/Bee_UIProgressView.h b/BeeFramework/MVC/View/Bee_UIProgressView.h index 9dda7b9..4d2c071 100644 --- a/BeeFramework/MVC/View/Bee_UIProgressView.h +++ b/BeeFramework/MVC/View/Bee_UIProgressView.h @@ -38,5 +38,6 @@ @interface BeeUIProgressView : UIProgressView + (BeeUIProgressView *)spawn; ++ (BeeUIProgressView *)spawn:(NSString *)tagString; @end diff --git a/BeeFramework/MVC/View/Bee_UIProgressView.m b/BeeFramework/MVC/View/Bee_UIProgressView.m index 9ddea0d..29fe8cc 100644 --- a/BeeFramework/MVC/View/Bee_UIProgressView.m +++ b/BeeFramework/MVC/View/Bee_UIProgressView.m @@ -34,6 +34,7 @@ #import "Bee_UIProgressView.h" #import "Bee_UISignal.h" #import "Bee_SystemInfo.h" +#import "UIView+BeeExtension.h" #pragma mark - @@ -48,6 +49,13 @@ + (BeeUIProgressView *)spawn return [[[BeeUIProgressView alloc] init] autorelease]; } ++ (BeeUIProgressView *)spawn:(NSString *)tagString +{ + BeeUIProgressView * view = [[[BeeUIProgressView alloc] init] autorelease]; + view.tagString = tagString; + return view; +} + - (id)init { self = [super initWithFrame:CGRectZero]; diff --git a/BeeFramework/MVC/View/Bee_UIPullLoader.h b/BeeFramework/MVC/View/Bee_UIPullLoader.h index 7fec06c..137b949 100644 --- a/BeeFramework/MVC/View/Bee_UIPullLoader.h +++ b/BeeFramework/MVC/View/Bee_UIPullLoader.h @@ -40,7 +40,7 @@ @interface BeeUIPullLoader : UIView { NSInteger _state; - UIImageView * _arrowView; + UIImageView * _arrow; BeeUIActivityIndicatorView * _indicator; } @@ -48,14 +48,18 @@ AS_INT( STATE_NORMAL ) AS_INT( STATE_PULLING ) AS_INT( STATE_LOADING ) +AS_SIGNAL( STATE_CHANGED ) // 状态改变 + @property (nonatomic, readonly) NSInteger state; @property (nonatomic, assign) BOOL normal; @property (nonatomic, assign) BOOL pulling; @property (nonatomic, assign) BOOL loading; - -AS_SIGNAL( STATE_CHANGED ) // 状态改变 + +@property (nonatomic, readonly) UIImageView * arrow; +@property (nonatomic, readonly) BeeUIActivityIndicatorView * indicator; + (BeeUIPullLoader *)spawn; ++ (BeeUIPullLoader *)spawn:(NSString *)tagString; - (void)changeState:(NSInteger)state; - (void)changeState:(NSInteger)state animated:(BOOL)animated; diff --git a/BeeFramework/MVC/View/Bee_UIPullLoader.m b/BeeFramework/MVC/View/Bee_UIPullLoader.m index 72c5940..e9a16cf 100644 --- a/BeeFramework/MVC/View/Bee_UIPullLoader.m +++ b/BeeFramework/MVC/View/Bee_UIPullLoader.m @@ -34,7 +34,8 @@ #import "Bee_UIPullLoader.h" #import "Bee_UIActivityIndicatorView.h" #import "Bee_UISignal.h" -#import "UIView+BeeQuery.h" +#import "UIView+BeeExtension.h" +#import "UIView+BeeUISignal.h" #pragma mark - @@ -51,15 +52,25 @@ @implementation BeeUIPullLoader DEF_INT( STATE_LOADING, 2 ) @synthesize state = _state; -@synthesize normal = _normal; -@synthesize pulling = _pulling; -@synthesize loading = _loading; +@synthesize arrow = _arrow; +@synthesize indicator = _indicator; + +@dynamic normal; +@dynamic pulling; +@dynamic loading; + (BeeUIPullLoader *)spawn { return [[[BeeUIPullLoader alloc] init] autorelease]; } ++ (BeeUIPullLoader *)spawn:(NSString *)tagString +{ + BeeUIPullLoader * view = [[[BeeUIPullLoader alloc] init] autorelease]; + view.tagString = tagString; + return view; +} + - (id)init { self = [super init]; @@ -77,6 +88,7 @@ - (id)initWithFrame:(CGRect)frame if ( self ) { [self initSelf]; + [self changeFrame:frame]; } return self; @@ -87,11 +99,11 @@ - (void)initSelf self.backgroundColor = [UIColor clearColor]; self.autoresizingMask = UIViewAutoresizingFlexibleWidth; - _arrowView = [[UIImageView alloc] initWithFrame:CGRectZero]; - _arrowView.contentMode = UIViewContentModeCenter; - _arrowView.backgroundColor = [UIColor clearColor]; - _arrowView.hidden = NO; - [self addSubview:_arrowView]; + _arrow = [[UIImageView alloc] initWithFrame:CGRectZero]; + _arrow.contentMode = UIViewContentModeCenter; + _arrow.backgroundColor = [UIColor clearColor]; + _arrow.hidden = NO; + [self addSubview:_arrow]; _indicator = [[BeeUIActivityIndicatorView alloc] initWithFrame:CGRectZero]; _indicator.hidden = YES; @@ -101,16 +113,14 @@ - (void)initSelf _state = BeeUIPullLoader.STATE_NORMAL; } -- (void)setFrame:(CGRect)frame +- (void)changeFrame:(CGRect)frame { - [super setFrame:frame]; - CGRect imageFrame; imageFrame.size.width = frame.size.height; imageFrame.size.height = frame.size.height; imageFrame.origin.x = (frame.size.width - imageFrame.size.width) / 2.0f; imageFrame.origin.y = (frame.size.height - imageFrame.size.height) / 2.0f; - _arrowView.frame = imageFrame; + _arrow.frame = imageFrame; CGRect indicatorFrame; indicatorFrame.size.width = 20.0f; @@ -120,9 +130,16 @@ - (void)setFrame:(CGRect)frame _indicator.frame = indicatorFrame; } +- (void)setFrame:(CGRect)frame +{ + [super setFrame:frame]; + + [self changeFrame:frame]; +} + - (void)dealloc { - SAFE_RELEASE_SUBVIEW( _arrowView ); + SAFE_RELEASE_SUBVIEW( _arrow ); SAFE_RELEASE_SUBVIEW( _indicator ); [super dealloc]; @@ -183,8 +200,8 @@ - (void)changeState:(NSInteger)state animated:(BOOL)animated { [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.3f]; - _arrowView.hidden = NO; - _arrowView.transform = CGAffineTransformIdentity; + _arrow.hidden = NO; + _arrow.transform = CGAffineTransformIdentity; [UIView commitAnimations]; [_indicator stopAnimating]; @@ -193,8 +210,8 @@ - (void)changeState:(NSInteger)state animated:(BOOL)animated { [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.3f]; - _arrowView.hidden = NO; - _arrowView.transform = CGAffineTransformRotate( CGAffineTransformIdentity, (M_PI / 360.0f) * -359.0f ); + _arrow.hidden = NO; + _arrow.transform = CGAffineTransformRotate( CGAffineTransformIdentity, (M_PI / 360.0f) * -359.0f ); [UIView commitAnimations]; } else if ( BeeUIPullLoader.STATE_LOADING == state ) @@ -203,7 +220,7 @@ - (void)changeState:(NSInteger)state animated:(BOOL)animated [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:0.3f]; - _arrowView.hidden = YES; + _arrow.hidden = YES; [UIView commitAnimations]; } diff --git a/BeeFramework/MVC/View/Bee_UIScrollView.h b/BeeFramework/MVC/View/Bee_UIScrollView.h index bf8475b..e1205b1 100644 --- a/BeeFramework/MVC/View/Bee_UIScrollView.h +++ b/BeeFramework/MVC/View/Bee_UIScrollView.h @@ -63,6 +63,7 @@ NSInteger _total; NSMutableArray * _items; + BOOL _reloaded; BOOL _reloading; UIEdgeInsets _baseInsets; @@ -84,6 +85,7 @@ AS_INT( DIRECTION_VERTICAL ) @property (nonatomic, readonly) NSRange visibleRange; @property (nonatomic, readonly) NSUInteger visiblePageIndex; +@property (nonatomic, assign) BOOL reloaded; @property (nonatomic, readonly) BOOL reloading; @property (nonatomic, retain) NSMutableArray * reuseQueue; @@ -98,6 +100,7 @@ AS_SIGNAL( DID_STOP ) AS_SIGNAL( DID_SCROLL ) + (BeeUIScrollView *)spawn; ++ (BeeUIScrollView *)spawn:(NSString *)tagString; - (UIView *)dequeueWithContentClass:(Class)clazz; diff --git a/BeeFramework/MVC/View/Bee_UIScrollView.m b/BeeFramework/MVC/View/Bee_UIScrollView.m index 05338e8..ce1be68 100644 --- a/BeeFramework/MVC/View/Bee_UIScrollView.m +++ b/BeeFramework/MVC/View/Bee_UIScrollView.m @@ -34,6 +34,8 @@ #import "Bee_UIScrollView.h" #import "Bee_Runtime.h" #import "Bee_Log.h" +#import "UIView+BeeExtension.h" +#import "UIView+BeeUISignal.h" #pragma mark - @@ -140,6 +142,7 @@ @implementation BeeUIScrollView @dynamic visibleRange; @dynamic visiblePageIndex; +@synthesize reloaded = _reloaded; @synthesize reloading = _reloading; @synthesize reuseQueue = _reuseQueue; @@ -151,6 +154,13 @@ + (BeeUIScrollView *)spawn return [[[BeeUIScrollView alloc] initWithFrame:CGRectZero] autorelease]; } ++ (BeeUIScrollView *)spawn:(NSString *)tagString +{ + BeeUIScrollView * view = [[[BeeUIScrollView alloc] init] autorelease]; + view.tagString = tagString; + return view; +} + - (id)init { self = [super initWithFrame:CGRectZero]; @@ -176,6 +186,7 @@ - (void)initSelf _direction = BeeUIScrollView.DIRECTION_VERTICAL; _dataSource = self; + _reloaded = NO; _lineCount = 0; _total = 0; @@ -275,13 +286,15 @@ - (NSRange)visibleRange - (NSUInteger)visiblePageIndex { + // special thanks to @Royall + if ( BeeUIScrollView.DIRECTION_HORIZONTAL == _direction ) { - return (NSUInteger)floorf(self.contentOffset.x / self.contentSize.width); + return (NSUInteger)floorf(_total - ((self.contentSize.width - self.contentOffset.x) / self.bounds.size.width) + 0.5); } else { - return (NSUInteger)floorf(self.contentOffset.y / self.contentSize.width); + return (NSUInteger)floorf(_total - ((self.contentSize.height - self.contentOffset.y) / self.bounds.size.height) + 0.5); } } @@ -352,7 +365,8 @@ - (void)operateReloadData { if ( YES == _reloading ) { - _reloading = NO; + _reloading = NO; + [self internalReloadData]; [self sendUISignal:BeeUIScrollView.RELOADED]; } @@ -372,14 +386,22 @@ - (void)internalReloadData [self releaseAllViews]; [self calcPositions]; [self syncPositions]; + + _reloaded = YES; } - (void)setFrame:(CGRect)frame { [super setFrame:frame]; - [self syncReloadData]; - [self syncPositions]; + if ( NO == _reloaded ) + { + [self syncReloadData]; + } + else + { + [self asyncReloadData]; + } } - (void)scrollToFirstPage:(BOOL)animated diff --git a/BeeFramework/MVC/View/Bee_UISegmentedControl.h b/BeeFramework/MVC/View/Bee_UISegmentedControl.h index 1a6c1c3..2a350a3 100644 --- a/BeeFramework/MVC/View/Bee_UISegmentedControl.h +++ b/BeeFramework/MVC/View/Bee_UISegmentedControl.h @@ -45,6 +45,7 @@ AS_SIGNAL( HIGHLIGHT_CHANGED ) // 高亮改变 @property (nonatomic, assign) NSInteger selectedTag; + (BeeUISegmentedControl *)spawn; ++ (BeeUISegmentedControl *)spawn:(NSString *)tagString; - (void)addTitle:(NSString *)title; - (void)addTitle:(NSString *)title tag:(NSInteger)tag; diff --git a/BeeFramework/MVC/View/Bee_UISegmentedControl.m b/BeeFramework/MVC/View/Bee_UISegmentedControl.m index 75b194b..22004bc 100644 --- a/BeeFramework/MVC/View/Bee_UISegmentedControl.m +++ b/BeeFramework/MVC/View/Bee_UISegmentedControl.m @@ -33,6 +33,8 @@ #import "Bee_Precompile.h" #import "Bee_UISegmentedControl.h" #import "Bee_UISignal.h" +#import "UIView+BeeExtension.h" +#import "UIView+BeeUISignal.h" #pragma mark - @@ -54,6 +56,13 @@ + (BeeUISegmentedControl *)spawn return [[[BeeUISegmentedControl alloc] initWithItems:[NSArray array]] autorelease]; } ++ (BeeUISegmentedControl *)spawn:(NSString *)tagString +{ + BeeUISegmentedControl * view = [[[BeeUISegmentedControl alloc] init] autorelease]; + view.tagString = tagString; + return view; +} + - (id)init { self = [super init]; diff --git a/BeeFramework/MVC/View/Bee_UISignal.h b/BeeFramework/MVC/View/Bee_UISignal.h index c3ed856..86a1425 100644 --- a/BeeFramework/MVC/View/Bee_UISignal.h +++ b/BeeFramework/MVC/View/Bee_UISignal.h @@ -43,6 +43,7 @@ @interface NSObject(BeeUISignalResponder) + (NSString *)SIGNAL; ++ (NSString *)SIGNAL_TYPE; - (BOOL)isUISignalResponder; @@ -109,40 +110,3 @@ AS_STATIC_PROPERTY( NO_VALUE ); - (void)returnNO; @end - -#pragma mark - - -@interface UIView(BeeUISignal) - -- (void)handleUISignal:(BeeUISignal *)signal; - -- (BeeUISignal *)sendUISignal:(NSString *)name; -- (BeeUISignal *)sendUISignal:(NSString *)name withObject:(NSObject *)object; -- (BeeUISignal *)sendUISignal:(NSString *)name withObject:(NSObject *)object from:(id)source; - -@end - -#pragma mark - - -@interface UIViewController(BeeUISignal) - -- (void)handleUISignal:(BeeUISignal *)signal; - -- (BeeUISignal *)sendUISignal:(NSString *)name; -- (BeeUISignal *)sendUISignal:(NSString *)name withObject:(NSObject *)object; -- (BeeUISignal *)sendUISignal:(NSString *)name withObject:(NSObject *)object from:(id)source; - -@end - -#pragma mark - - -@interface UIView(BeeTappable) - -AS_SIGNAL( TAPPED ); - -- (void)makeTappable; -- (void)makeTappable:(NSString *)signal; -- (void)makeTappable:(NSString *)signal withObject:(NSObject *)obj; -- (void)makeUntappable; - -@end diff --git a/BeeFramework/MVC/View/Bee_UISignal.m b/BeeFramework/MVC/View/Bee_UISignal.m index add54a7..59b7590 100644 --- a/BeeFramework/MVC/View/Bee_UISignal.m +++ b/BeeFramework/MVC/View/Bee_UISignal.m @@ -35,6 +35,7 @@ #import "Bee_Singleton.h" #import "Bee_Log.h" #import "Bee_Performance.h" +#import "UIView+BeeExtension.h" #import @@ -48,6 +49,11 @@ @implementation NSObject(BeeUISignalResponder) + (NSString *)SIGNAL +{ + return [self SIGNAL_TYPE]; +} + ++ (NSString *)SIGNAL_TYPE { return [NSString stringWithFormat:@"signal.%@.", [self description]]; } @@ -157,7 +163,7 @@ - (BOOL)send } #endif // #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ - if ( [_target isUISignalResponder] ) + if ( [_target isKindOfClass:[UIView class]] || [_target isKindOfClass:[UIViewController class]] ) { _jump = 1; @@ -186,7 +192,7 @@ - (BOOL)forward:(id)target } #endif // #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ - if ( [target isUISignalResponder] ) + if ( [_target isKindOfClass:[UIView class]] || [_target isKindOfClass:[UIViewController class]] ) { _jump += 1; @@ -210,15 +216,59 @@ - (void)routes { // NSString * prefix = (NSString *)[array objectAtIndex:0]; NSString * clazz = (NSString *)[array objectAtIndex:1]; + NSString * method = (NSString *)[array objectAtIndex:2]; - NSString * selectorName = [NSString stringWithFormat:@"handle%@:", clazz]; - SEL selector = NSSelectorFromString(selectorName); + NSObject * targetObject = _target; - if ( [_target respondsToSelector:selector] ) + if ( [_target isKindOfClass:[UIView class]] ) { - [_target performSelector:selector withObject:self]; - return; + UIViewController * viewController = [(UIView *)_target viewController]; + if ( viewController ) + { + targetObject = viewController; + } + } + + #if defined(__BEE_SELECTOR_STYLE2__) && __BEE_SELECTOR_STYLE2__ + { + NSString * selectorName; + SEL selector; + + selectorName = [NSString stringWithFormat:@"handleUISignal_%@_%@:", clazz, method]; + selector = NSSelectorFromString(selectorName); + + if ( [targetObject respondsToSelector:selector] ) + { + [targetObject performSelector:selector withObject:self]; + return; + } + + selectorName = [NSString stringWithFormat:@"handleUISignal_%@:", clazz]; + selector = NSSelectorFromString(selectorName); + + if ( [targetObject respondsToSelector:selector] ) + { + [targetObject performSelector:selector withObject:self]; + return; + } + } + #endif // #if defined(__BEE_SELECTOR_STYLE2__) && __BEE_SELECTOR_STYLE2__ + + #if defined(__BEE_SELECTOR_STYLE1__) && __BEE_SELECTOR_STYLE1__ + { + NSString * selectorName; + SEL selector; + + selectorName = [NSString stringWithFormat:@"handle%@:", clazz]; + selector = NSSelectorFromString(selectorName); + + if ( [targetObject respondsToSelector:selector] ) + { + [targetObject performSelector:selector withObject:self]; + return; + } } + #endif // #if defined(__BEE_SELECTOR_STYLE1__) && __BEE_SELECTOR_STYLE1__ } Class rtti = [_source class]; @@ -241,7 +291,10 @@ - (void)routes if ( nil == rtti ) { - [_target handleUISignal:self]; + if ( [_target respondsToSelector:@selector(handleUISignal:)] ) + { + [_target performSelector:@selector(handleUISignal:) withObject:self]; + } } } @@ -319,199 +372,3 @@ - (void)dealloc } @end - -#pragma mark - - -@implementation UIView(BeeUISignal) - -- (void)handleUISignal:(BeeUISignal *)signal -{ - if ( self.superview ) - { - [signal forward:self.superview]; - } - else - { - signal.reach = YES; - - #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ - CC( @"[%@] > %@", signal.name, signal.callPath ); - #endif // #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ - } -} - -- (BeeUISignal *)sendUISignal:(NSString *)name -{ - return [self sendUISignal:name withObject:nil from:self]; -} - -- (BeeUISignal *)sendUISignal:(NSString *)name withObject:(NSObject *)object -{ - return [self sendUISignal:name withObject:object from:self]; -} - -- (BeeUISignal *)sendUISignal:(NSString *)name withObject:(NSObject *)object from:(id)source -{ - BeeUISignal * signal = [[[BeeUISignal alloc] init] autorelease]; - if ( signal ) - { - signal.source = source ? source : self; - signal.target = self; - signal.name = name; - signal.object = object; - [signal send]; - } - return signal; -} - -@end - -#pragma mark - - -@implementation UIViewController(BeeUISignal) - -- (void)handleUISignal:(BeeUISignal *)signal -{ - signal.reach = YES; - -#if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ - CC( @"[%@] > %@", signal.name, signal.callPath ); -#endif // #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ -} - -- (BeeUISignal *)sendUISignal:(NSString *)name -{ - return [self sendUISignal:name withObject:nil from:self]; -} - -- (BeeUISignal *)sendUISignal:(NSString *)name withObject:(NSObject *)object -{ - return [self sendUISignal:name withObject:object from:self]; -} - -- (BeeUISignal *)sendUISignal:(NSString *)name withObject:(NSObject *)object from:(id)source -{ - BeeUISignal * signal = [[[BeeUISignal alloc] init] autorelease]; - if ( signal ) - { - signal.source = source ? source : self; - signal.target = self; - signal.name = name; - signal.object = object; - [signal send]; - } - return signal; -} - -@end - -#pragma mark - - -@interface UISingleTapGestureRecognizer : UITapGestureRecognizer -{ - NSString * _signalName; - NSObject * _signalObject; -} - -@property (nonatomic, retain) NSString * signalName; -@property (nonatomic, assign) NSObject * signalObject; - -@end - -#pragma mark - - -@implementation UISingleTapGestureRecognizer - -@synthesize signalName = _signalName; -@synthesize signalObject = _signalObject; - -- (id)initWithTarget:(id)target action:(SEL)action -{ - self = [super initWithTarget:target action:action]; - if ( self ) - { - self.numberOfTapsRequired = 1; - self.numberOfTouchesRequired = 1; - self.cancelsTouchesInView = YES; - self.delaysTouchesBegan = YES; - self.delaysTouchesEnded = YES; - } - return self; -} - -- (void)dealloc -{ - [super dealloc]; -} - -@end - -#pragma mark - - -@implementation UIView(BeeTappable) - -DEF_SIGNAL( TAPPED ); - -- (void)didSingleTapped:(UITapGestureRecognizer *)tapGesture -{ - if ( [tapGesture isKindOfClass:[UISingleTapGestureRecognizer class]] ) - { - UISingleTapGestureRecognizer * gesture = (UISingleTapGestureRecognizer *)tapGesture; - if ( UIGestureRecognizerStateEnded == gesture.state ) - { - if ( gesture.signalName ) - { - [self sendUISignal:gesture.signalName withObject:gesture.signalObject]; - } - else - { - [self sendUISignal:UIView.TAPPED]; - } - } - } -} - -- (void)makeTappable -{ - [self makeTappable:nil]; -} - -- (void)makeTappable:(NSString *)signal -{ - [self makeTappable:signal withObject:nil]; -} - -- (void)makeTappable:(NSString *)signal withObject:(NSObject *)obj -{ - self.userInteractionEnabled = YES; - - UISingleTapGestureRecognizer * singleTapGesture = nil; - for ( UITapGestureRecognizer * gesture in self.gestureRecognizers ) - { - if ( [gesture isKindOfClass:[UISingleTapGestureRecognizer class]] ) - { - singleTapGesture = (UISingleTapGestureRecognizer *)gesture; - } - } - - if ( nil == singleTapGesture ) - { - singleTapGesture = [[[UISingleTapGestureRecognizer alloc] initWithTarget:self action:@selector(didSingleTapped:)] autorelease]; - [self addGestureRecognizer:singleTapGesture]; - } - - singleTapGesture.signalName = signal; - singleTapGesture.signalObject = obj; -} - -- (void)makeUntappable -{ - self.userInteractionEnabled = NO; - - for ( UITapGestureRecognizer * gesture in self.gestureRecognizers ) - { - [self removeGestureRecognizer:gesture]; - } -} - -@end diff --git a/BeeFramework/MVC/View/Bee_UITabBar.h b/BeeFramework/MVC/View/Bee_UITabBar.h index fd21433..b3e7fc6 100644 --- a/BeeFramework/MVC/View/Bee_UITabBar.h +++ b/BeeFramework/MVC/View/Bee_UITabBar.h @@ -37,24 +37,30 @@ @interface BeeUITabBar : UITabBar { - NSMutableArray * _barItems; + NSMutableDictionary * _barSignals; + NSMutableArray * _barItems; } AS_SIGNAL( HIGHLIGHT_CHANGED ) // 高亮改变 -@property (nonatomic, readonly) NSInteger selectedIndex; +@property (nonatomic, assign) NSInteger selectedIndex; +@property (nonatomic, assign) NSInteger selectedTag; + (BeeUITabBar *)spawn; ++ (BeeUITabBar *)spawn:(NSString *)tagString; -- (void)hilite:(NSInteger)tag; +- (void)hilite:(NSInteger)tag; // use selectedIndex instead - (void)addTitle:(NSString *)title; - (void)addTitle:(NSString *)title tag:(NSInteger)tag; +- (void)addTitle:(NSString *)title tag:(NSInteger)tag signal:(NSString *)signal; - (void)addImage:(UIImage *)image; - (void)addImage:(UIImage *)image tag:(NSInteger)tag; +- (void)addImage:(UIImage *)image tag:(NSInteger)tag signal:(NSString *)signal; - (void)addTitle:(NSString *)title image:(UIImage *)image; - (void)addTitle:(NSString *)title image:(UIImage *)image tag:(NSInteger)tag; +- (void)addTitle:(NSString *)title image:(UIImage *)image tag:(NSInteger)tag signal:(NSString *)signal; @end diff --git a/BeeFramework/MVC/View/Bee_UITabBar.m b/BeeFramework/MVC/View/Bee_UITabBar.m index 90c3cdf..e14e979 100644 --- a/BeeFramework/MVC/View/Bee_UITabBar.m +++ b/BeeFramework/MVC/View/Bee_UITabBar.m @@ -33,6 +33,8 @@ #import "Bee_Precompile.h" #import "Bee_UITabBar.h" #import "Bee_UISignal.h" +#import "UIView+BeeExtension.h" +#import "UIView+BeeUISignal.h" #pragma mark - @@ -46,13 +48,21 @@ @implementation BeeUITabBar DEF_SIGNAL( HIGHLIGHT_CHANGED ) -@synthesize selectedIndex; +@dynamic selectedIndex; +@dynamic selectedTag; + (BeeUITabBar *)spawn { return [[[BeeUITabBar alloc] initWithFrame:CGRectZero] autorelease]; } ++ (BeeUITabBar *)spawn:(NSString *)tagString +{ + BeeUITabBar * view = [[[BeeUITabBar alloc] init] autorelease]; + view.tagString = tagString; + return view; +} + - (id)init { if( (self = [super initWithFrame:CGRectZero]) ) @@ -80,10 +90,14 @@ - (void)initSelf self.selectedItem = nil; _barItems = [[NSMutableArray alloc] init]; + _barSignals = [[NSMutableDictionary alloc] init]; } - (void)dealloc { + [_barSignals removeAllObjects]; + [_barSignals release]; + [_barItems removeAllObjects]; [_barItems release]; @@ -92,14 +106,7 @@ - (void)dealloc - (void)hilite:(NSInteger)tag { - for ( UITabBarItem * item in _barItems ) - { - if ( item.tag == tag ) - { - self.selectedItem = item; - break; - } - } + [self setSelectedTag:tag]; } - (void)addTitle:(NSString *)title @@ -112,6 +119,11 @@ - (void)addTitle:(NSString *)title tag:(NSInteger)tag; [self addTitle:title image:nil tag:tag]; } +- (void)addTitle:(NSString *)title tag:(NSInteger)tag signal:(NSString *)signal +{ + [self addTitle:title image:nil tag:tag signal:signal]; +} + - (void)addImage:(UIImage *)image { [self addTitle:nil image:image tag:_barItems.count]; @@ -122,16 +134,34 @@ - (void)addImage:(UIImage *)image tag:(NSInteger)tag [self addTitle:nil image:image tag:tag]; } +- (void)addImage:(UIImage *)image tag:(NSInteger)tag signal:(NSString *)signal +{ + [self addTitle:nil image:image tag:tag signal:signal]; +} + - (void)addTitle:(NSString *)title image:(UIImage *)image { [self addTitle:title image:image tag:_barItems.count]; } - (void)addTitle:(NSString *)title image:(UIImage *)image tag:(NSInteger)tag +{ + [self addTitle:title image:image tag:tag signal:nil]; +} + +- (void)addTitle:(NSString *)title image:(UIImage *)image tag:(NSInteger)tag signal:(NSString *)signal { UITabBarItem * item = [[[UITabBarItem alloc] initWithTitle:title image:image tag:tag] autorelease]; - [_barItems addObject:item]; - [self setItems:_barItems animated:NO]; + if ( item ) + { + [_barItems addObject:item]; + [self setItems:_barItems animated:NO]; + + if ( signal ) + { + [_barSignals setObject:signal forKey:[NSString stringWithFormat:@"%p", item]]; + } + } } - (NSInteger)selectedIndex @@ -147,13 +177,57 @@ - (NSInteger)selectedIndex return -1; } +- (void)setSelectedIndex:(NSInteger)index +{ + if ( index < _barItems.count ) + { + UITabBarItem * item = [_barItems objectAtIndex:index]; + + [self setSelectedItem:item]; + [self tabBar:self didSelectItem:item]; + } + else + { + [self setSelectedItem:nil]; +// [self tabBar:self didSelectItem:item]; + } +} + +- (NSInteger)selectedTag +{ + return self.selectedItem.tag; +} + +- (void)setSelectedTag:(NSInteger)tag +{ + for ( UITabBarItem * item in _barItems ) + { + if ( item.tag == tag ) + { + [self setSelectedItem:item]; + [self tabBar:self didSelectItem:item]; + break; + } + } +} + #pragma mark - // called when a new view is selected by the user (but not programatically) - (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item { - [self sendUISignal:BeeUITabBar.HIGHLIGHT_CHANGED - withObject:[NSNumber numberWithInt:item.tag]]; + NSString * key = [NSString stringWithFormat:@"%p", item]; + NSString * signal = [_barSignals objectForKey:key]; + if ( signal ) + { + [self sendUISignal:signal + withObject:[NSNumber numberWithInt:item.tag]]; + } + else + { + [self sendUISignal:BeeUITabBar.HIGHLIGHT_CHANGED + withObject:[NSNumber numberWithInt:item.tag]]; + } } @end diff --git a/BeeFramework/MVC/View/Bee_UITextField.h b/BeeFramework/MVC/View/Bee_UITextField.h index 979ca75..66b3686 100644 --- a/BeeFramework/MVC/View/Bee_UITextField.h +++ b/BeeFramework/MVC/View/Bee_UITextField.h @@ -58,5 +58,6 @@ AS_SIGNAL( CLEAR ) // 清空 AS_SIGNAL( RETURN ) // 换行 + (BeeUITextField *)spawn; ++ (BeeUITextField *)spawn:(NSString *)tagString; @end diff --git a/BeeFramework/MVC/View/Bee_UITextField.m b/BeeFramework/MVC/View/Bee_UITextField.m index 694152b..c3ac518 100644 --- a/BeeFramework/MVC/View/Bee_UITextField.m +++ b/BeeFramework/MVC/View/Bee_UITextField.m @@ -33,6 +33,7 @@ #import "Bee_Precompile.h" #import "Bee_UITextField.h" #import "Bee_UISignal.h" +#import "UIView+BeeExtension.h" #pragma mark - @@ -143,6 +144,13 @@ + (BeeUITextField *)spawn return [[[BeeUITextField alloc] initWithFrame:CGRectZero] autorelease]; } ++ (BeeUITextField *)spawn:(NSString *)tagString +{ + BeeUITextField * view = [[[BeeUITextField alloc] init] autorelease]; + view.tagString = tagString; + return view; +} + - (id)init { if( (self = [super initWithFrame:CGRectZero]) ) diff --git a/BeeFramework/MVC/View/Bee_UITextView.h b/BeeFramework/MVC/View/Bee_UITextView.h index 5a7ebda..5f88887 100644 --- a/BeeFramework/MVC/View/Bee_UITextView.h +++ b/BeeFramework/MVC/View/Bee_UITextView.h @@ -64,6 +64,7 @@ AS_SIGNAL( RETURN ) // 换行 @property (nonatomic, assign) NSObject * nextChain; + (BeeUITextView *)spawn; ++ (BeeUITextView *)spawn:(NSString *)tagString; - (void)updatePlaceHolder; diff --git a/BeeFramework/MVC/View/Bee_UITextView.m b/BeeFramework/MVC/View/Bee_UITextView.m index b165aaf..1ec98df 100644 --- a/BeeFramework/MVC/View/Bee_UITextView.m +++ b/BeeFramework/MVC/View/Bee_UITextView.m @@ -33,6 +33,8 @@ #import "Bee_Precompile.h" #import "Bee_UITextView.h" #import "Bee_UISignal.h" +#import "UIView+BeeExtension.h" +#import "UIView+BeeUISignal.h" #pragma mark - @@ -149,6 +151,13 @@ + (BeeUITextView *)spawn return [[[BeeUITextView alloc] initWithFrame:CGRectZero] autorelease]; } ++ (BeeUITextView *)spawn:(NSString *)tagString +{ + BeeUITextView * view = [[[BeeUITextView alloc] init] autorelease]; + view.tagString = tagString; + return view; +} + - (id)init { self = [super initWithFrame:CGRectZero]; diff --git a/BeeFramework/MVC/View/Bee_UITipsView.h b/BeeFramework/MVC/View/Bee_UITipsView.h new file mode 100644 index 0000000..a05e4e7 --- /dev/null +++ b/BeeFramework/MVC/View/Bee_UITipsView.h @@ -0,0 +1,180 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_UITipsView.h +// + +#import +#import "Bee_UISignal.h" +#import "Bee_Singleton.h" + +#pragma mark - + +@class BeeUITipsView; + +@interface NSObject(BeeUITipsView) + +- (BeeUITipsView *)presentingTips; + +- (BeeUITipsView *)presentMessageTips:(NSString *)message; +- (BeeUITipsView *)presentSuccessTips:(NSString *)message; +- (BeeUITipsView *)presentFailureTips:(NSString *)message; +- (BeeUITipsView *)presentLoadingTips:(NSString *)message; +- (BeeUITipsView *)presentProgressTips:(NSString *)message; + +- (void)dismissTips; + +@end + +#pragma mark - + +@interface BeeUITipsView : UIView +{ + NSTimeInterval _timerSeconds; + NSTimer * _timer; + + BOOL _useMask; + BOOL _useScaling; + BOOL _useBounces; + BOOL _interrupt; // 是否可被打断 + BOOL _timeLimit; + BOOL _exclusive; // 是否独占模式,其他区域不能点击? + BOOL _fullScreen; +} + +AS_SIGNAL( WILL_APPEAR ); // 将要显示 +AS_SIGNAL( DID_APPEAR ); // 已经显示 +AS_SIGNAL( WILL_DISAPPEAR ); // 将要隐藏 +AS_SIGNAL( DID_DISAPPEAR ); // 已经隐藏 + +@property (nonatomic, assign) NSTimeInterval timerSeconds; +@property (nonatomic, assign) BOOL useMask; +@property (nonatomic, assign) BOOL useScaling; +@property (nonatomic, assign) BOOL useBounces; +@property (nonatomic, assign) BOOL interrupt; +@property (nonatomic, assign) BOOL timeLimit; +@property (nonatomic, assign) BOOL exclusive; +@property (nonatomic, assign) BOOL fullScreen; + +- (void)present; +- (void)presentInView:(UIView *)view; +- (void)dismiss; + +@end + +#pragma mark - + +@interface BeeUIMessageTipsView : BeeUITipsView +{ + UIImageView * _bubbleView; + UIImageView * _iconView; + UILabel * _labelView; +} + +@property (nonatomic, retain) UIImageView * bubbleView; +@property (nonatomic, retain) UIImageView * iconView; +@property (nonatomic, retain) UILabel * labelView; + +@end + +#pragma mark - + +@interface BeeUILoadingTipsView : BeeUITipsView +{ + UIImageView * _bubbleView; + UIActivityIndicatorView * _indicator; + UILabel * _labelView; +} + +@property (nonatomic, retain) UIImageView * bubbleView; +@property (nonatomic, retain) UIActivityIndicatorView * indicator; +@property (nonatomic, retain) UILabel * labelView; + +@end + +#pragma mark - + +@interface BeeUIProgressTipsView : BeeUITipsView +{ + UIImageView * _bubbleView; + UIProgressView * _indicator; + UILabel * _labelView; +} + +@property (nonatomic, retain) UIImageView * bubbleView; +@property (nonatomic, retain) UIProgressView * indicator; +@property (nonatomic, retain) UILabel * labelView; + +- (void)updateProgress:(float)percent; + +@end + +#pragma mark - + +@interface BeeUITipsCenter : NSObject +{ + UIView * _defaultContainerView; + UIButton * _maskView; + BeeUITipsView * _tipsAppear; + BeeUITipsView * _tipsDisappear; + + UIImage * _bubble; + UIImage * _messageIcon; + UIImage * _successIcon; + UIImage * _failureIcon; +} + +@property (nonatomic, assign) UIView * defaultContainerView; +@property (nonatomic, retain) UIView * maskView; +@property (nonatomic, retain) BeeUITipsView * tipsAppear; +@property (nonatomic, retain) BeeUITipsView * tipsDisappear; + +@property (nonatomic, retain) UIImage * bubble; +@property (nonatomic, retain) UIImage * messageIcon; +@property (nonatomic, retain) UIImage * successIcon; +@property (nonatomic, retain) UIImage * failureIcon; + +AS_SINGLETON( BeeUITipsCenter ) + ++ (void)setDefaultContainerView:(UIView *)view; ++ (void)setDefaultMessageIcon:(UIImage *)image; ++ (void)setDefaultSuccessIcon:(UIImage *)image; ++ (void)setDefaultFailureIcon:(UIImage *)image; ++ (void)setDefaultBubble:(UIImage *)image; + +- (void)dismissTips; +- (void)dismissTipsByOwner:(UIView *)parentView; + +- (BeeUITipsView *)presentMessageTips:(NSString *)message inView:(UIView *)view; +- (BeeUITipsView *)presentSuccessTips:(NSString *)message inView:(UIView *)view; +- (BeeUITipsView *)presentFailureTips:(NSString *)message inView:(UIView *)view; +- (BeeUITipsView *)presentLoadingTips:(NSString *)message inView:(UIView *)view; +- (BeeUITipsView *)presentProgressTips:(NSString *)message inView:(UIView *)view; + +@end diff --git a/BeeFramework/MVC/View/Bee_UITipsView.m b/BeeFramework/MVC/View/Bee_UITipsView.m new file mode 100644 index 0000000..a3df9fb --- /dev/null +++ b/BeeFramework/MVC/View/Bee_UITipsView.m @@ -0,0 +1,879 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_UITipsView.m +// + +#import +#import "Bee_UITipsView.h" +#import "Bee_UIKeyboard.h" +#import "UIView+BeeExtension.h" +#import "UIImage+BeeExtension.h" +#import "NSObject+BeeNotification.h" +#import "UIView+BeeUISignal.h" + +#define DEFAULT_TIPS_BUBBLE_WIDTH (160.0f) +#define DEFAULT_TIPS_BUBBLE_HEIGHT (140.0f) +#define DEFAULT_TIMEOUT_SECONDS (1.0f) +#define ANIMATION_DURATION (0.3f) + +#pragma mark - + +@implementation NSObject(BeeUITipsView) + +- (BeeUITipsView *)presentingTips +{ + return [BeeUITipsCenter sharedInstance].tipsAppear; +} + +- (BeeUITipsView *)presentMessageTips:(NSString *)message +{ + UIView * container = nil; + + if ( [self isKindOfClass:[UIView class]] ) + { + container = (UIView *)self; + } + else if ( [self isKindOfClass:[UIViewController class]] ) + { + container = ((UIViewController *)self).view; + } + + return [[BeeUITipsCenter sharedInstance] presentMessageTips:message inView:container]; +} + +- (BeeUITipsView *)presentSuccessTips:(NSString *)message +{ + UIView * container = nil; + + if ( [self isKindOfClass:[UIView class]] ) + { + container = (UIView *)self; + } + else if ( [self isKindOfClass:[UIViewController class]] ) + { + container = ((UIViewController *)self).view; + } + + return [[BeeUITipsCenter sharedInstance] presentSuccessTips:message inView:container]; +} + +- (BeeUITipsView *)presentFailureTips:(NSString *)message +{ + UIView * container = nil; + + if ( [self isKindOfClass:[UIView class]] ) + { + container = (UIView *)self; + } + else if ( [self isKindOfClass:[UIViewController class]] ) + { + container = ((UIViewController *)self).view; + } + + return [[BeeUITipsCenter sharedInstance] presentFailureTips:message inView:container]; +} + +- (BeeUITipsView *)presentLoadingTips:(NSString *)message +{ + UIView * container = nil; + + if ( [self isKindOfClass:[UIView class]] ) + { + container = (UIView *)self; + } + else if ( [self isKindOfClass:[UIViewController class]] ) + { + container = ((UIViewController *)self).view; + } + + return [[BeeUITipsCenter sharedInstance] presentLoadingTips:message inView:container]; +} + +- (BeeUITipsView *)presentProgressTips:(NSString *)message +{ + UIView * container = nil; + + if ( [self isKindOfClass:[UIView class]] ) + { + container = (UIView *)self; + } + else if ( [self isKindOfClass:[UIViewController class]] ) + { + container = ((UIViewController *)self).view; + } + + return [[BeeUITipsCenter sharedInstance] presentProgressTips:message inView:container]; +} + +- (void)dismissTips +{ + UIView * container = nil; + + if ( [self isKindOfClass:[UIView class]] ) + { + container = (UIView *)self; + } + else if ( [self isKindOfClass:[UIViewController class]] ) + { + container = ((UIViewController *)self).view; + } + + return [[BeeUITipsCenter sharedInstance] dismissTipsByOwner:container]; +} + +@end + +#pragma mark - + +@interface BeeUITipsCenter(Private) +- (void)presentTips:(BeeUITipsView *)tips inView:(UIView *)view; +- (void)dismissTips; +- (void)dismissTipsByOwner:(UIView *)parentView; +- (void)dismissTipsLoading; +- (void)performDismissTips; +- (void)didAppearingAnimationDone; +- (void)didDisappearingAnimationDone; +- (void)bounce1ForAppearingAnimationStopped; +- (void)bounce2ForAppearingAnimationStopped; +@end + +@interface BeeUITipsView(Private) +- (void)didTimeout; +- (void)internalWillAppear; +- (void)internalDidAppear; +- (void)internalWillDisappear; +- (void)internalDidDisappear; +- (void)internalRelayout:(UIView *)parentView; +@end + +#pragma mark - + +@implementation BeeUITipsCenter + +DEF_SINGLETON( BeeUITipsCenter ) + +@synthesize defaultContainerView = _defaultContainerView; + +@synthesize maskView = _maskView; +@synthesize tipsAppear = _tipsAppear; +@synthesize tipsDisappear = _tipsDisappear; + +@synthesize bubble = _bubble; +@synthesize messageIcon = _messageIcon; +@synthesize successIcon = _successIcon; +@synthesize failureIcon = _failureIcon; + ++ (void)setDefaultContainerView:(UIView *)view +{ + [BeeUITipsCenter sharedInstance].defaultContainerView = view; +} + ++ (void)setDefaultMessageIcon:(UIImage *)image +{ + [BeeUITipsCenter sharedInstance].messageIcon = image; +} + ++ (void)setDefaultSuccessIcon:(UIImage *)image +{ + [BeeUITipsCenter sharedInstance].successIcon = image; +} + ++ (void)setDefaultFailureIcon:(UIImage *)image +{ + [BeeUITipsCenter sharedInstance].failureIcon = image; +} + ++ (void)setDefaultBubble:(UIImage *)image +{ + [BeeUITipsCenter sharedInstance].bubble = image; +} + +- (id)init +{ + self = [super init]; + if ( self ) + { + _defaultContainerView = nil; + _tipsAppear = nil; + _tipsDisappear = nil; + + _maskView = [[UIButton alloc] initWithFrame:[UIScreen mainScreen].bounds]; + _maskView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.05f]; + + [self observeNotification:BeeUIKeyboard.SHOWN]; + [self observeNotification:BeeUIKeyboard.HIDDEN]; + [self observeNotification:BeeUIKeyboard.HEIGHT_CHANGED]; + } + + return self; +} + +- (void)dealloc +{ + [self unobserveAllNotifications]; + + [_tipsAppear release]; + [_tipsDisappear release]; + + [_bubble release]; + [_messageIcon release]; + [_failureIcon release]; + [_successIcon release]; + + [super dealloc]; +} + +- (void)handleNotification:(NSNotification *)notification +{ + if ( [notification is:BeeUIKeyboard.SHOWN] || [notification is:BeeUIKeyboard.HEIGHT_CHANGED] ) + { + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:0.2f]; + [_tipsAppear internalRelayout:_tipsAppear.superview]; + [_tipsDisappear internalRelayout:_tipsDisappear.superview]; + [UIView commitAnimations]; + } + else if ( [notification is:BeeUIKeyboard.HIDDEN] ) + { + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:0.2f]; + [_tipsAppear internalRelayout:_tipsAppear.superview]; + [_tipsDisappear internalRelayout:_tipsDisappear.superview]; + [UIView commitAnimations]; + } +} + +- (void)presentTipsView:(BeeUITipsView *)tips inView:(UIView *)view +{ + if ( nil != _tipsAppear ) + { + if ( tips == _tipsAppear ) + return; + + if ( NO == _tipsAppear.interrupt ) + return; + } + + if ( nil == view ) + { + view = _defaultContainerView; + + if ( nil == view ) + { + view = [UIApplication sharedApplication].keyWindow; + } + } + + [tips internalRelayout:view]; + + tips.backgroundColor = [UIColor clearColor]; + + self.tipsDisappear = self.tipsAppear; + self.tipsAppear = tips; + + [_maskView removeFromSuperview]; + [view addSubview:_maskView]; + [view bringSubviewToFront:_maskView]; + + _maskView.frame = view.bounds; + + [view addSubview:_tipsAppear]; + [view bringSubviewToFront:_tipsAppear]; + +// animation 1 + + _tipsAppear.alpha = 0.0f; + + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationBeginsFromCurrentState:YES]; + [UIView setAnimationDuration:ANIMATION_DURATION]; + [UIView setAnimationDelegate:self]; + [UIView setAnimationDidStopSelector:@selector(didAppearingAnimationDone)]; + + _tipsAppear.alpha = 1.0f; + _tipsDisappear.alpha = 0.0f; + _maskView.alpha = _tipsAppear.useMask ? 1.0f : 0.0f; + + [UIView commitAnimations]; + +// animation 2 + + if ( _tipsAppear.useScaling ) + { + _tipsAppear.transform = CGAffineTransformMakeScale( 1.2f, 1.2f ); + + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:ANIMATION_DURATION]; + [UIView setAnimationBeginsFromCurrentState:YES]; + + _tipsAppear.transform = CGAffineTransformMakeScale( 1.0f, 1.0f ); + _tipsDisappear.transform = CGAffineTransformMakeScale( 0.8f, 0.8f ); + + [UIView commitAnimations]; + } + +// animation 3 + + if ( _tipsAppear.useBounces ) + { + _tipsAppear.transform = CGAffineTransformScale( CGAffineTransformIdentity, 0.001, 0.001 ); + + [UIView beginAnimations:nil context:nil]; + [UIView setAnimationDuration:(ANIMATION_DURATION / 1.5)]; + [UIView setAnimationDelegate:self]; + [UIView setAnimationDidStopSelector:@selector(bounce1ForAppearingAnimationStopped)]; + + _tipsAppear.transform = CGAffineTransformScale( CGAffineTransformIdentity, 1.1f, 1.1f ); + + [UIView commitAnimations]; + } + + [_tipsAppear internalWillAppear]; + [_tipsDisappear internalWillDisappear]; +} + +- (void)didAppearingAnimationDone +{ + if ( NO == _tipsAppear.useMask ) + { + _maskView.alpha = 0.0f; + [_maskView removeFromSuperview]; + } + + [_tipsDisappear removeFromSuperview]; + _tipsDisappear = nil; + + [_tipsAppear internalDidAppear]; + [_tipsDisappear internalDidDisappear]; +} + +- (void)bounce1ForAppearingAnimationStopped +{ + [UIView beginAnimations:nil context:nil]; + [UIView setAnimationDuration:(ANIMATION_DURATION / 2.0f)]; + [UIView setAnimationDelegate:self]; + [UIView setAnimationDidStopSelector:@selector(bounce2ForAppearingAnimationStopped)]; + + _tipsAppear.transform = CGAffineTransformScale( CGAffineTransformIdentity, 0.9, 0.9 ); + + [UIView commitAnimations]; +} + +- (void)bounce2ForAppearingAnimationStopped +{ + [UIView beginAnimations:nil context:nil]; + [UIView setAnimationDuration:(ANIMATION_DURATION / 2.0f)]; + + _tipsAppear.transform = CGAffineTransformIdentity; + + [UIView commitAnimations]; +} + +- (void)dismissTips +{ + [self performDismissTips]; +} + +- (void)dismissTipsByOwner:(UIView *)parentView +{ + if ( _tipsAppear && _tipsAppear.superview == parentView ) + { + [self performDismissTips]; + } +} + +- (void)performDismissTips +{ + if ( nil == _tipsAppear ) + return; + + self.tipsDisappear = self.tipsAppear; + self.tipsAppear = nil; + + [UIView beginAnimations:nil context:NULL]; + [UIView setAnimationDuration:0.3f]; + [UIView setAnimationDelegate:self]; + [UIView setAnimationDidStopSelector:@selector(didDisappearingAnimationDone)]; + + _tipsDisappear.alpha = 0.0f; + + if ( _tipsDisappear.useScaling ) + { + _tipsDisappear.transform = CGAffineTransformMakeScale( 0.8f, 0.8f ); + } + + _maskView.alpha = 0.0f; + + [UIView commitAnimations]; + + [_tipsAppear internalWillAppear]; + [_tipsDisappear internalWillDisappear]; +} + +- (void)didDisappearingAnimationDone +{ + if ( NO == _tipsAppear.useMask ) + { + _maskView.alpha = 0.0f; + [_maskView removeFromSuperview]; + } + + [_tipsDisappear removeFromSuperview]; + _tipsDisappear = nil; + + [_tipsAppear internalDidAppear]; + [_tipsDisappear internalDidDisappear]; +} + +- (BeeUITipsView *)presentMessageTips:(NSString *)message inView:(UIView *)view +{ + BeeUIMessageTipsView * tips = [[BeeUIMessageTipsView alloc] init]; + tips.iconView.image = _messageIcon; + tips.labelView.text = message; + [tips presentInView:view]; + return [tips autorelease]; +} + +- (BeeUITipsView *)presentSuccessTips:(NSString *)message inView:(UIView *)view +{ + BeeUIMessageTipsView * tips = [[BeeUIMessageTipsView alloc] init]; + tips.iconView.image = _successIcon; + tips.labelView.text = message; + [tips presentInView:view]; + return [tips autorelease]; +} + +- (BeeUITipsView *)presentFailureTips:(NSString *)message inView:(UIView *)view +{ + BeeUIMessageTipsView * tips = [[BeeUIMessageTipsView alloc] init]; + tips.iconView.image = _failureIcon; + tips.labelView.text = message; + [tips presentInView:view]; + return [tips autorelease]; +} + +- (BeeUITipsView *)presentLoadingTips:(NSString *)message inView:(UIView *)view +{ + BeeUILoadingTipsView * tips = [[BeeUILoadingTipsView alloc] init]; + tips.labelView.text = message; + [tips presentInView:view]; + [tips.indicator startAnimating]; + return [tips autorelease]; +} + +- (BeeUITipsView *)presentProgressTips:(NSString *)message inView:(UIView *)view +{ + BeeUIProgressTipsView * tips = [[BeeUIProgressTipsView alloc] init]; + tips.labelView.text = message; + [tips presentInView:view]; + [tips updateProgress:0.0f]; + return [tips autorelease]; +} + +@end + +#pragma mark - + +@implementation BeeUITipsView + +@synthesize timerSeconds = _timerSeconds; + +@synthesize useMask = _useMask; +@synthesize useScaling = _useScaling; +@synthesize useBounces = _useBounces; +@synthesize interrupt = _interrupt; +@synthesize timeLimit = _timeLimit; +@synthesize exclusive = _exclusive; +@synthesize fullScreen = _fullScreen; + +DEF_SIGNAL( WILL_APPEAR ); +DEF_SIGNAL( DID_APPEAR ); +DEF_SIGNAL( WILL_DISAPPEAR ); +DEF_SIGNAL( DID_DISAPPEAR ); + +- (id)init +{ + self = [super initWithFrame:CGRectZero]; + if ( self ) + { + self.backgroundColor = [UIColor clearColor]; + self.timerSeconds = DEFAULT_TIMEOUT_SECONDS; + self.timeLimit = YES; + self.interrupt = YES; + self.fullScreen = NO; +// self.useScaling = YES; +// self.useBounces = YES; + } + + return self; +} + +- (void)dealloc +{ + [_timer invalidate]; + _timer = nil; + + [super dealloc]; +} + +- (void)internalWillAppear +{ + [_timer invalidate]; + _timer = nil; + + [self sendUISignal:BeeUITipsView.WILL_APPEAR]; +} + +- (void)internalDidAppear +{ + [_timer invalidate]; + _timer = nil; + + if ( _timeLimit ) + { + _timer = [NSTimer scheduledTimerWithTimeInterval:self.timerSeconds + target:self + selector:@selector(dismiss) + userInfo:nil + repeats:NO]; + } + + [self sendUISignal:BeeUITipsView.DID_APPEAR]; +} + +- (void)internalWillDisappear +{ + [_timer invalidate]; + _timer = nil; + + [self sendUISignal:BeeUITipsView.WILL_DISAPPEAR]; +} + +- (void)internalDidDisappear +{ + [self sendUISignal:BeeUITipsView.DID_DISAPPEAR]; +} + +- (void)internalRelayout:(UIView *)parentView +{ + if ( _fullScreen ) + { + self.frame = parentView.bounds; + } + else + { + CGRect bound = parentView.bounds; + + if ( [BeeUIKeyboard sharedInstance].shown ) + { + bound.size.height -= [BeeUIKeyboard sharedInstance].height; + } + + bound.origin.y += 44.0f; + bound.size.height -= 44.0f; + + CGRect viewFrame; + viewFrame.origin.x = bound.origin.x + (bound.size.width - DEFAULT_TIPS_BUBBLE_WIDTH) / 2.0f; + viewFrame.origin.y = bound.origin.y + (bound.size.height - DEFAULT_TIPS_BUBBLE_HEIGHT) / 2.0f; + viewFrame.size.width = DEFAULT_TIPS_BUBBLE_WIDTH; + viewFrame.size.height = DEFAULT_TIPS_BUBBLE_HEIGHT; + + self.frame = viewFrame; + } +} + +- (void)presentInView:(UIView *)view +{ + [[BeeUITipsCenter sharedInstance] presentTipsView:self inView:view]; +} + +- (void)present +{ + [[BeeUITipsCenter sharedInstance] presentTipsView:self inView:nil]; +} + +- (void)dismiss +{ + [_timer invalidate]; + _timer = nil; + + [[BeeUITipsCenter sharedInstance] dismissTips]; +} + +@end + +#pragma mark - + +@implementation BeeUIMessageTipsView + +@synthesize bubbleView = _bubbleView; +@synthesize iconView = _iconView; +@synthesize labelView = _labelView; + +- (id)init +{ + self = [super init]; + if ( self ) + { + self.useMask = YES; + self.interrupt = YES; + self.exclusive = NO; + self.timeLimit = YES; + self.timerSeconds = DEFAULT_TIMEOUT_SECONDS; + + _bubbleView = [[UIImageView alloc] initWithFrame:CGRectZero]; + _bubbleView.backgroundColor = [UIColor clearColor]; + _bubbleView.contentMode = UIViewContentModeCenter; + _bubbleView.image = [BeeUITipsCenter sharedInstance].bubble.stretched; + [self addSubview:_bubbleView]; + + _iconView = [[UIImageView alloc] initWithFrame:CGRectZero]; + _iconView.backgroundColor = [UIColor clearColor]; + _iconView.contentMode = UIViewContentModeCenter; + [self addSubview:_iconView]; + + _labelView = [[UILabel alloc] initWithFrame:CGRectZero]; + _labelView.font = [UIFont boldSystemFontOfSize:14.0f]; + _labelView.baselineAdjustment = UIBaselineAdjustmentAlignCenters; + _labelView.textAlignment = UITextAlignmentCenter; + _labelView.textColor = [UIColor whiteColor]; + _labelView.backgroundColor = [UIColor clearColor]; + _labelView.lineBreakMode = UILineBreakModeClip; + _labelView.numberOfLines = 2; + [self addSubview:_labelView]; + } + + return self; +} + +- (void)dealloc +{ + SAFE_RELEASE_SUBVIEW( _bubbleView ); + SAFE_RELEASE_SUBVIEW( _iconView ); + SAFE_RELEASE_SUBVIEW( _labelView ); + + [super dealloc]; +} + +- (void)internalRelayout:(UIView *)parentView +{ + [super internalRelayout:parentView]; + + _bubbleView.frame = self.bounds; + + if ( _iconView.image ) + { + CGRect iconFrame = self.bounds; + iconFrame.size.height -= 20.0f; + _iconView.frame = iconFrame; + + CGRect labelFrame; + labelFrame.size.width = self.bounds.size.width; + labelFrame.size.height = 60.0f; + labelFrame.origin.x = 0.0f; + labelFrame.origin.y = self.bounds.size.height - labelFrame.size.height; + _labelView.frame = CGRectInset(labelFrame, 5.0f, 0.0f); + } + else + { + _labelView.frame = CGRectInset(self.bounds, 5.0f, 0.0f); + } +} + +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event +{ + [super touchesBegan:touches withEvent:event]; + + [self dismiss]; +} + +@end + +#pragma mark - + +@implementation BeeUILoadingTipsView + +@synthesize bubbleView = _bubbleView; +@synthesize labelView = _labelView; +@synthesize indicator = _indicator; + +- (id)init +{ + self = [super init]; + if ( self ) + { + self.useMask = YES; + self.interrupt = NO; + self.exclusive = YES; + self.timeLimit = NO; + + _bubbleView = [[UIImageView alloc] initWithFrame:CGRectZero]; + _bubbleView.backgroundColor = [UIColor clearColor]; + _bubbleView.contentMode = UIViewContentModeCenter; + _bubbleView.image = [BeeUITipsCenter sharedInstance].bubble.stretched; + [self addSubview:_bubbleView]; + + _indicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectZero]; + _indicator.backgroundColor = [UIColor clearColor]; + [self addSubview:_indicator]; + + _labelView = [[UILabel alloc] initWithFrame:CGRectZero]; + _labelView.font = [UIFont boldSystemFontOfSize:14.0f]; + _labelView.baselineAdjustment = UIBaselineAdjustmentAlignCenters; + _labelView.textAlignment = UITextAlignmentCenter; + _labelView.textColor = [UIColor whiteColor]; + _labelView.backgroundColor = [UIColor clearColor]; + _labelView.lineBreakMode = UILineBreakModeClip; + _labelView.numberOfLines = 2; + [self addSubview:_labelView]; + } + + return self; +} + +- (void)dealloc +{ + SAFE_RELEASE_SUBVIEW( _bubbleView ); + SAFE_RELEASE_SUBVIEW( _indicator ); + SAFE_RELEASE_SUBVIEW( _labelView ); + + [super dealloc]; +} + +- (void)internalRelayout:(UIView *)parentView +{ + [super internalRelayout:parentView]; + + _bubbleView.frame = self.bounds; + + CGRect indicatorFrame; + indicatorFrame.size.width = 14.0f; + indicatorFrame.size.height = 14.0f; + indicatorFrame.origin.x = (self.bounds.size.width - indicatorFrame.size.width) / 2.0f; + indicatorFrame.origin.y = (self.bounds.size.height - indicatorFrame.size.height) / 2.0f; + _indicator.frame = indicatorFrame; + + CGRect labelFrame; + labelFrame.size.width = self.bounds.size.width; + labelFrame.size.height = 60.0f; + labelFrame.origin.x = 0.0f; + labelFrame.origin.y = self.bounds.size.height - labelFrame.size.height; + _labelView.frame = CGRectInset(labelFrame, 5.0f, 0.0f); +} + +@end + +#pragma mark - + +@implementation BeeUIProgressTipsView + +@synthesize bubbleView = _bubbleView; +@synthesize indicator = _indicator; +@synthesize labelView = _labelView; + +- (id)init +{ + self = [super init]; + if ( self ) + { + self.useMask = YES; + self.interrupt = NO; + self.exclusive = YES; + self.timeLimit = NO; + + _bubbleView = [[UIImageView alloc] initWithFrame:CGRectZero]; + _bubbleView.backgroundColor = [UIColor clearColor]; + _bubbleView.contentMode = UIViewContentModeCenter; + _bubbleView.image = [BeeUITipsCenter sharedInstance].bubble.stretched; + [self addSubview:_bubbleView]; + + _indicator = [[UIProgressView alloc] initWithFrame:CGRectZero]; + _indicator.backgroundColor = [UIColor clearColor]; + [self addSubview:_indicator]; + + _labelView = [[UILabel alloc] initWithFrame:CGRectZero]; + _labelView.font = [UIFont boldSystemFontOfSize:14.0f]; + _labelView.baselineAdjustment = UIBaselineAdjustmentAlignCenters; + _labelView.textAlignment = UITextAlignmentCenter; + _labelView.textColor = [UIColor whiteColor]; + _labelView.backgroundColor = [UIColor clearColor]; + _labelView.lineBreakMode = UILineBreakModeClip; + _labelView.numberOfLines = 2; + [self addSubview:_labelView]; + } + + return self; +} + +- (void)dealloc +{ + SAFE_RELEASE_SUBVIEW( _bubbleView ); + SAFE_RELEASE_SUBVIEW( _indicator ); + SAFE_RELEASE_SUBVIEW( _labelView ); + + [super dealloc]; +} + +- (void)updateProgress:(float)p +{ + if ( p <= 0.0f ) + { + _indicator.hidden = YES; + } + else + { + _indicator.hidden = NO; + } + + _indicator.progress = p;; +} + +- (void)internalRelayout:(UIView *)parentView +{ + [super internalRelayout:parentView]; + + _bubbleView.frame = self.bounds; + + CGRect indicatorRect; + indicatorRect.size.width = self.bounds.size.width - 40.0f; + indicatorRect.size.height = 20.0f; + indicatorRect.origin.x = (self.bounds.size.width - indicatorRect.size.width) / 2.0f; + indicatorRect.origin.y = (self.bounds.size.height - 20.0f - 20.0f) / 2.0f; + _indicator.frame = indicatorRect; + + CGRect labelFrame; + labelFrame.size.width = self.bounds.size.width; + labelFrame.size.height = 60.0f; + labelFrame.origin.x = 0.0f; + labelFrame.origin.y = self.bounds.size.height - labelFrame.size.height; + _labelView.frame = CGRectInset(labelFrame, 5.0f, 0.0f); +} + +@end diff --git a/BeeFramework/MVC/View/Bee_UIWebView.h b/BeeFramework/MVC/View/Bee_UIWebView.h index 0864db4..7e8513e 100644 --- a/BeeFramework/MVC/View/Bee_UIWebView.h +++ b/BeeFramework/MVC/View/Bee_UIWebView.h @@ -56,5 +56,6 @@ AS_SIGNAL( DID_LOAD_CANCELLED ) // 加载取消 @property (nonatomic, assign) NSString * url; + (BeeUIWebView *)spawn; ++ (BeeUIWebView *)spawn:(NSString *)tagString; @end diff --git a/BeeFramework/MVC/View/Bee_UIWebView.m b/BeeFramework/MVC/View/Bee_UIWebView.m index 4af9baf..c0e0dfe 100644 --- a/BeeFramework/MVC/View/Bee_UIWebView.m +++ b/BeeFramework/MVC/View/Bee_UIWebView.m @@ -34,6 +34,8 @@ #import "Bee_UIWebView.h" #import "Bee_UISignal.h" #import "Bee_Log.h" +#import "UIView+BeeExtension.h" +#import "UIView+BeeUISignal.h" #pragma mark - @@ -68,6 +70,13 @@ + (BeeUIWebView *)spawn return [[[BeeUIWebView alloc] initWithFrame:CGRectZero] autorelease]; } ++ (BeeUIWebView *)spawn:(NSString *)tagString +{ + BeeUIWebView * view = [[[BeeUIWebView alloc] init] autorelease]; + view.tagString = tagString; + return view; +} + - (id)init { if( (self = [super initWithFrame:CGRectZero]) ) diff --git a/BeeFramework/MVC/View/Bee_UIZoomView.h b/BeeFramework/MVC/View/Bee_UIZoomView.h index d4cc7d0..456965b 100644 --- a/BeeFramework/MVC/View/Bee_UIZoomView.h +++ b/BeeFramework/MVC/View/Bee_UIZoomView.h @@ -77,6 +77,7 @@ AS_SIGNAL( DOUBLE_TAPPED ); @property (nonatomic, retain) UIView * content; + (BeeUIZoomView *)spawn; ++ (BeeUIZoomView *)spawn:(NSString *)tagString; - (void)resetZoom; - (void)layoutContent; diff --git a/BeeFramework/MVC/View/Bee_UIZoomView.m b/BeeFramework/MVC/View/Bee_UIZoomView.m index cedf0b7..c2fa8ac 100644 --- a/BeeFramework/MVC/View/Bee_UIZoomView.m +++ b/BeeFramework/MVC/View/Bee_UIZoomView.m @@ -33,10 +33,11 @@ #import "Bee_Precompile.h" #import "Bee_UIZoomView.h" #import "Bee_UISignal.h" -#import "UIView+BeeQuery.h" +#import "UIView+BeeExtension.h" #import "CGRect+BeeExtension.h" #import "NSNumber+BeeExtension.h" +#import "UIView+BeeUISignal.h" #pragma mark - @@ -178,6 +179,13 @@ + (BeeUIZoomView *)spawn return [[[BeeUIZoomView alloc] init] autorelease]; } ++ (BeeUIZoomView *)spawn:(NSString *)tagString +{ + BeeUIZoomView * view = [[[BeeUIZoomView alloc] init] autorelease]; + view.tagString = tagString; + return view; +} + - (id)init { self = [super init]; diff --git a/BeeFramework/MVC/Bee_View.h b/BeeFramework/MVC/View/Bee_View.h similarity index 85% rename from BeeFramework/MVC/Bee_View.h rename to BeeFramework/MVC/View/Bee_View.h index 74b9540..3dcc171 100644 --- a/BeeFramework/MVC/Bee_View.h +++ b/BeeFramework/MVC/View/Bee_View.h @@ -30,9 +30,6 @@ // Bee_View.h // -#import "Bee_Precompile.h" - -// View #import "Bee_UIActionSheet.h" #import "Bee_UIAlertView.h" #import "Bee_UIActivityIndicatorView.h" @@ -51,6 +48,7 @@ #import "Bee_UITabBar.h" #import "Bee_UITextField.h" #import "Bee_UITextView.h" +#import "Bee_UITipsView.h" #import "Bee_UIWebView.h" #import "Bee_UIZoomView.h" @@ -58,16 +56,10 @@ #import "UIFont+BeeExtension.h" #import "UIColor+BeeExtension.h" #import "UIImage+BeeExtension.h" +#import "UIView+BeeExtension.h" -#import "UIView+BeeBackground.h" -#import "UIView+BeeQuery.h" -#import "UIView+BeeWireframe.h" - -// ViewController -#import "Bee_UIBoard.h" -#import "Bee_UIStack.h" -#import "Bee_UIStackGroup.h" -#import "Bee_UICameraBoard.h" -#import "Bee_UIFlowBoard.h" -#import "Bee_UITableBoard.h" -#import "Bee_UIWebBoard.h" +#import "UIView+BeeUISignal.h" +#import "UIView+HoldGesture.h" +#import "UIView+PanGesture.h" +#import "UIView+SwipeGesture.h" +#import "UIView+TapGesture.h" diff --git a/BeeFramework/MVC/Bee_View.m b/BeeFramework/MVC/View/Bee_View.m similarity index 100% rename from BeeFramework/MVC/Bee_View.m rename to BeeFramework/MVC/View/Bee_View.m diff --git a/BeeFramework/MVC/View/CGRect+BeeExtension.h b/BeeFramework/MVC/View/Extension/CGRect+BeeExtension.h similarity index 100% rename from BeeFramework/MVC/View/CGRect+BeeExtension.h rename to BeeFramework/MVC/View/Extension/CGRect+BeeExtension.h diff --git a/BeeFramework/MVC/View/CGRect+BeeExtension.m b/BeeFramework/MVC/View/Extension/CGRect+BeeExtension.m similarity index 100% rename from BeeFramework/MVC/View/CGRect+BeeExtension.m rename to BeeFramework/MVC/View/Extension/CGRect+BeeExtension.m diff --git a/BeeFramework/MVC/View/UIColor+BeeExtension.h b/BeeFramework/MVC/View/Extension/UIColor+BeeExtension.h similarity index 100% rename from BeeFramework/MVC/View/UIColor+BeeExtension.h rename to BeeFramework/MVC/View/Extension/UIColor+BeeExtension.h diff --git a/BeeFramework/MVC/View/UIColor+BeeExtension.m b/BeeFramework/MVC/View/Extension/UIColor+BeeExtension.m similarity index 100% rename from BeeFramework/MVC/View/UIColor+BeeExtension.m rename to BeeFramework/MVC/View/Extension/UIColor+BeeExtension.m diff --git a/BeeFramework/MVC/View/UIFont+BeeExtension.h b/BeeFramework/MVC/View/Extension/UIFont+BeeExtension.h similarity index 100% rename from BeeFramework/MVC/View/UIFont+BeeExtension.h rename to BeeFramework/MVC/View/Extension/UIFont+BeeExtension.h diff --git a/BeeFramework/MVC/View/UIFont+BeeExtension.m b/BeeFramework/MVC/View/Extension/UIFont+BeeExtension.m similarity index 100% rename from BeeFramework/MVC/View/UIFont+BeeExtension.m rename to BeeFramework/MVC/View/Extension/UIFont+BeeExtension.m diff --git a/BeeFramework/MVC/View/UIImage+BeeExtension.h b/BeeFramework/MVC/View/Extension/UIImage+BeeExtension.h similarity index 100% rename from BeeFramework/MVC/View/UIImage+BeeExtension.h rename to BeeFramework/MVC/View/Extension/UIImage+BeeExtension.h diff --git a/BeeFramework/MVC/View/UIImage+BeeExtension.m b/BeeFramework/MVC/View/Extension/UIImage+BeeExtension.m similarity index 100% rename from BeeFramework/MVC/View/UIImage+BeeExtension.m rename to BeeFramework/MVC/View/Extension/UIImage+BeeExtension.m diff --git a/BeeFramework/MVC/View/UIView+BeeQuery.h b/BeeFramework/MVC/View/Extension/UIView+BeeExtension.h similarity index 76% rename from BeeFramework/MVC/View/UIView+BeeQuery.h rename to BeeFramework/MVC/View/Extension/UIView+BeeExtension.h index 2086dc3..9634151 100644 --- a/BeeFramework/MVC/View/UIView+BeeQuery.h +++ b/BeeFramework/MVC/View/Extension/UIView+BeeExtension.h @@ -27,7 +27,7 @@ // IN THE SOFTWARE. // // -// UIView+BeeQuery.h +// UIView+BeeExtension.h // #import "Bee_Precompile.h" @@ -54,6 +54,21 @@ #pragma mark - -@interface UIView(BeeQuery) +@interface UIView(BeeExtension) + +@property (nonatomic, retain) NSString * tagString; +@property (nonatomic, retain) NSString * hintString; +@property (nonatomic, retain) UIColor * hintColor; + +@property (nonatomic, retain) BeeUIImageView * backgroundImageView; +@property (nonatomic, retain) UIImage * backgroundImage; + +- (UIView *)viewWithTagString:(NSString *)value; +- (UIView *)viewAtPath:(NSString *)name; - (UIView *)subview:(NSString *)name; +- (UIViewController *)viewController; + ++ (UIView *)spawn; ++ (UIView *)spawn:(NSString *)tagString; + @end diff --git a/BeeFramework/MVC/View/Extension/UIView+BeeExtension.m b/BeeFramework/MVC/View/Extension/UIView+BeeExtension.m new file mode 100644 index 0000000..91cb347 --- /dev/null +++ b/BeeFramework/MVC/View/Extension/UIView+BeeExtension.m @@ -0,0 +1,332 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// UIView+BeeBackground.m +// + +#import "Bee_Precompile.h" +#import "Bee_UISignal.h" +#import "Bee_UIImageView.h" +#import "Bee_UILabel.h" +#import "UIView+BeeExtension.h" +#include +#include + +#pragma mark - + +@interface __BeeHintLabel : BeeUILabel +@end + +@implementation __BeeHintLabel + +- (id)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if ( self ) + { + self.autoresizesSubviews = YES; + self.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth; + + self.alpha = 0.6f; + self.backgroundColor = [UIColor clearColor]; + self.userInteractionEnabled = NO; + + self.textColor = [UIColor whiteColor]; + self.textAlignment = UITextAlignmentCenter; + self.font = [UIFont boldSystemFontOfSize:24.0f]; + self.lineBreakMode = UILineBreakModeClip; + self.numberOfLines = 1; + } + + return self; +} + +- (void)drawRect:(CGRect)rect +{ + CGContextRef context = UIGraphicsGetCurrentContext(); + if ( context ) + { + CGContextSaveGState( context ); + + CGContextSetStrokeColorWithColor( context, [UIColor colorWithWhite:0.3f alpha:1.0f].CGColor ); + CGContextMoveToPoint( context, 0.0f, 0.0f ); + CGContextAddLineToPoint( context, self.bounds.size.width, self.bounds.size.height ); + CGContextStrokePath( context ); + + CGContextSetStrokeColorWithColor( context, [UIColor colorWithWhite:0.3f alpha:1.0f].CGColor ); + CGContextMoveToPoint( context, 0.0f, self.bounds.size.height ); + CGContextAddLineToPoint( context, self.bounds.size.width, 0.0f ); + CGContextStrokePath( context ); + + CGContextRestoreGState( context ); + } + + [super drawRect:rect]; +} + +@end + +#pragma mark - + +@interface __BeeBackgroundImageView : BeeUIImageView +@end + +@implementation __BeeBackgroundImageView +@end + +#pragma mark - + +@implementation UIView(BeeExtension) + +@dynamic tagString; +@dynamic hintString; +@dynamic hintColor; +@dynamic backgroundImageView; +@dynamic backgroundImage; + +- (__BeeBackgroundImageView *)__backgroundImageView +{ + __BeeBackgroundImageView * result = nil; + + for ( UIView * subView in self.subviews ) + { + if ( [subView isKindOfClass:[__BeeBackgroundImageView class]] ) + { + result = (__BeeBackgroundImageView *)subView; + break; + } + } + + return result; +} + +- (BeeUIImageView *)backgroundImageView +{ + return [self __backgroundImageView]; +} + +- (void)setBackgroundImageView:(BeeUIImageView *)backgroundImageView +{ + NSAssert( @"TO BE DONE", nil ); +} + +- (UIImage *)backgroundImage +{ + __BeeBackgroundImageView * imageView = [self __backgroundImageView]; + if ( imageView ) + { + return imageView.image; + } + + return nil; +} + +- (void)setBackgroundImage:(UIImage *)image +{ + if ( image ) + { + __BeeBackgroundImageView * imageView = [self __backgroundImageView]; + if ( nil == imageView ) + { + imageView = [[[__BeeBackgroundImageView alloc] initWithFrame:self.bounds] autorelease]; + [self addSubview:imageView]; + [self sendSubviewToBack:imageView]; + } + + imageView.autoresizesSubviews = YES; + imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; + imageView.image = image; + imageView.frame = self.bounds; + imageView.contentMode = UIViewContentModeCenter; + [imageView setNeedsDisplay]; + } + else + { + __BeeBackgroundImageView * imageView = [self __backgroundImageView]; + if ( imageView ) + { + [imageView removeFromSuperview]; + } + } +} + +- (NSString *)tagString +{ + NSObject * obj = objc_getAssociatedObject( self, "UIView.tagString" ); + if ( obj && [obj isKindOfClass:[NSString class]] ) + return (NSString *)obj; + + return nil; +} + +- (void)setTagString:(NSString *)value +{ + objc_setAssociatedObject( self, "UIView.tagString", value, OBJC_ASSOCIATION_RETAIN ); +} + +- (UIView *)viewWithTagString:(NSString *)value +{ + if ( nil == value ) + return nil; + + for ( UIView * subview in self.subviews ) + { + if ( [subview.tagString isEqualToString:value] ) + { + return subview; + } + } + + return nil; +} + +- (UIView *)viewAtPath:(NSString *)path +{ + if ( nil == path || 0 == path.length ) + return nil; + + NSString * keyPath = [path stringByReplacingOccurrencesOfString:@"/" withString:@"."]; + NSRange range = NSMakeRange( 0, 1 ); + + if ( [[keyPath substringWithRange:range] isEqualToString:@"."] ) + { + keyPath = [keyPath substringFromIndex:1]; + } + + NSObject * result = [self valueForKeyPath:keyPath]; + if ( result == [NSNull null] || NO == [result isKindOfClass:[UIView class]] ) + return nil; + + return (UIView *)result; +} + +- (UIView *)subview:(NSString *)name +{ + if ( nil == name || 0 == [name length] ) + return nil; + + NSObject * view = [self valueForKey:name]; + + if ( [view isKindOfClass:[UIView class]] ) + { + return (UIView *)view; + } + else + { + return nil; + } +} + +- (UIViewController *)viewController +{ + if ( nil != self.superview ) + return nil; + + id nextResponder = [self nextResponder]; + if ( [nextResponder isKindOfClass:[UIViewController class]] ) + { + return (UIViewController *)nextResponder; + } + else + { + return nil; + } +} + +- (__BeeHintLabel *)__hintLabel +{ +#if defined(__BEE_WIREFRAME__) && __BEE_WIREFRAME__ + + __BeeHintLabel * hintLabel = nil; + + for ( UIView * subView in self.subviews ) + { + if ( [subView isKindOfClass:[__BeeHintLabel class]] ) + { + hintLabel = (__BeeHintLabel *)subView; + break; + } + } + + if ( nil == hintLabel ) + { + hintLabel = [[[__BeeHintLabel alloc] initWithFrame:self.bounds] autorelease]; + hintLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; + hintLabel.backgroundColor = [UIColor darkGrayColor]; + [self addSubview:hintLabel]; + } + + hintLabel.frame = self.bounds; + [hintLabel setNeedsDisplay]; + + [self setAutoresizesSubviews:YES]; + [self sendSubviewToBack:hintLabel]; + + return hintLabel; + +#else // #if defined(__BEE_WIREFRAME__) && __BEE_WIREFRAME__ + + return nil; + +#endif // #if defined(__BEE_WIREFRAME__) && __BEE_WIREFRAME__ +} + +- (NSString *)hintString +{ + return [self __hintLabel].text; +} + +- (void)setHintString:(NSString *)string +{ + [self __hintLabel].text = string; +} + +- (UIColor *)hintColor +{ + return [self __hintLabel].backgroundColor; +} + +- (void)setHintColor:(UIColor *)color +{ + [self __hintLabel].backgroundColor = color; +} + ++ (UIView *)spawn +{ + return [[[[self class] alloc] init] autorelease]; +} + ++ (UIView *)spawn:(NSString *)tagString +{ + UIView * view = [self spawn]; + view.tagString = tagString; + return view; +} + +@end diff --git a/BeeFramework/MVC/View/UIView+BeeWireframe.h b/BeeFramework/MVC/View/Extension/UIView+BeeUISignal.h similarity index 78% rename from BeeFramework/MVC/View/UIView+BeeWireframe.h rename to BeeFramework/MVC/View/Extension/UIView+BeeUISignal.h index b0e1339..7d6b4da 100644 --- a/BeeFramework/MVC/View/UIView+BeeWireframe.h +++ b/BeeFramework/MVC/View/Extension/UIView+BeeUISignal.h @@ -27,22 +27,23 @@ // IN THE SOFTWARE. // // -// UIView+BeeWireframe.h +// UIView+BeeUISignal.h // #import "Bee_Precompile.h" #import "Bee_UISignal.h" -#import "Bee_UIImageView.h" #pragma mark - -@interface UIView(BeeWireframe) +@interface UIView(BeeUISignal) -@property (nonatomic, assign) NSString * wireFrameTitle; -@property (nonatomic, assign) UIColor * wireFrameColor; ++ (NSString *)SIGNAL; ++ (NSString *)SIGNAL_TYPE; + +- (void)handleUISignal:(BeeUISignal *)signal; + +- (BeeUISignal *)sendUISignal:(NSString *)name; +- (BeeUISignal *)sendUISignal:(NSString *)name withObject:(NSObject *)object; +- (BeeUISignal *)sendUISignal:(NSString *)name withObject:(NSObject *)object from:(id)source; -- (void)showWireframe; -- (void)showWireframe:(NSString *)title; -- (void)showWireframe:(NSString *)title tintColor:(UIColor *)color; -- (void)hideWireframe; @end diff --git a/BeeFramework/MVC/View/Extension/UIView+BeeUISignal.m b/BeeFramework/MVC/View/Extension/UIView+BeeUISignal.m new file mode 100644 index 0000000..21d6612 --- /dev/null +++ b/BeeFramework/MVC/View/Extension/UIView+BeeUISignal.m @@ -0,0 +1,95 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_UISignal.m +// + +#import "Bee_Precompile.h" +#import "Bee_UISignal.h" +#import "Bee_Log.h" +#import "UIView+BeeUISignal.h" +#import "UIView+BeeExtension.h" + +#import + +#pragma mark - + +@implementation UIView(BeeUISignal) + ++ (NSString *)SIGNAL +{ + return [self SIGNAL_TYPE]; +} + ++ (NSString *)SIGNAL_TYPE +{ + return [NSString stringWithFormat:@"signal.%@.", [self description]]; +} + +- (void)handleUISignal:(BeeUISignal *)signal +{ + if ( self.superview ) + { + [signal forward:self.superview]; + } + else + { + signal.reach = YES; + + #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ + CC( @"[%@] > %@", signal.name, signal.callPath ); + #endif // #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ + } +} + +- (BeeUISignal *)sendUISignal:(NSString *)name +{ + return [self sendUISignal:name withObject:nil from:self]; +} + +- (BeeUISignal *)sendUISignal:(NSString *)name withObject:(NSObject *)object +{ + return [self sendUISignal:name withObject:object from:self]; +} + +- (BeeUISignal *)sendUISignal:(NSString *)name withObject:(NSObject *)object from:(id)source +{ + BeeUISignal * signal = [[[BeeUISignal alloc] init] autorelease]; + if ( signal ) + { + signal.source = source ? source : self; + signal.target = self; + signal.name = name; + signal.object = object; + [signal send]; + } + return signal; +} + +@end diff --git a/BeeFramework/MVC/View/UIView+BeeQuery.m b/BeeFramework/MVC/View/Extension/UIView+HoldGesture.h similarity index 78% rename from BeeFramework/MVC/View/UIView+BeeQuery.m rename to BeeFramework/MVC/View/Extension/UIView+HoldGesture.h index 7de6f38..0db1064 100644 --- a/BeeFramework/MVC/View/UIView+BeeQuery.m +++ b/BeeFramework/MVC/View/Extension/UIView+HoldGesture.h @@ -27,33 +27,22 @@ // IN THE SOFTWARE. // // -// UIView+BeeQuery.m +// UIView+HoldGesture.h // #import "Bee_Precompile.h" #import "Bee_UISignal.h" -#import "Bee_UIImageView.h" -#import "Bee_UILabel.h" -#import "UIView+BeeQuery.h" #pragma mark - -@implementation UIView(BeeQuery) +@interface UIView(HoldGesture) -- (UIView *)subview:(NSString *)name -{ - if ( nil == name || 0 == [name length] ) - return nil; - - NSObject * view = [self valueForKey:name]; - if ( [view isKindOfClass:[UIView class]] ) - { - return (UIView *)view; - } - else - { - return nil; - } -} +@property (nonatomic, assign) BOOL holdable; // same as holdEnabled +@property (nonatomic, assign) BOOL holdEnabled; +@property (nonatomic, readonly) UILongPressGestureRecognizer * holdGesture; + +AS_SIGNAL( HOLD_START ) // 长按开始 +AS_SIGNAL( HOLD_STOP ) // 长按结束 +AS_SIGNAL( HOLD_CANCELLED ) // 长按取消 @end diff --git a/BeeFramework/MVC/View/Extension/UIView+HoldGesture.m b/BeeFramework/MVC/View/Extension/UIView+HoldGesture.m new file mode 100644 index 0000000..8700486 --- /dev/null +++ b/BeeFramework/MVC/View/Extension/UIView+HoldGesture.m @@ -0,0 +1,166 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_UISignal.m +// + +#import "Bee_Precompile.h" +#import "Bee_UISignal.h" +#import "Bee_Singleton.h" +#import "Bee_Log.h" +#import "Bee_Performance.h" +#import "UIView+BeeExtension.h" +#import "UIView+BeeUISignal.h" +#import "UIView+HoldGesture.h" + +#import + +#pragma mark - + +@interface __LongPressGestureRecognizer : UILongPressGestureRecognizer +@end + +#pragma mark - + +@implementation __LongPressGestureRecognizer + +- (id)initWithTarget:(id)target action:(SEL)action +{ + self = [super initWithTarget:target action:action]; + if ( self ) + { + self.numberOfTapsRequired = 1; + self.numberOfTouchesRequired = 1; + self.cancelsTouchesInView = YES; + self.delaysTouchesBegan = YES; + self.delaysTouchesEnded = YES; + self.minimumPressDuration = 1.0f; + self.allowableMovement = 10; + } + return self; +} + +- (void)dealloc +{ + [super dealloc]; +} + +@end + +#pragma mark - + +@interface UIView(HoldGesturePrivate) +- (__LongPressGestureRecognizer *)getLongPressGesture; +@end + +#pragma mark - + +@implementation UIView(HoldGesture) + +DEF_SIGNAL( HOLD_START ) // 长按开始 +DEF_SIGNAL( HOLD_STOP ) // 长按结束 +DEF_SIGNAL( HOLD_CANCELLED ) // 长按取消 + +@dynamic holdable; // same as holdEnabled +@dynamic holdEnabled; +@dynamic holdGesture; + +- (__LongPressGestureRecognizer *)getLongPressGesture +{ + __LongPressGestureRecognizer * pressGesture = nil; + + for ( UIGestureRecognizer * gesture in self.gestureRecognizers ) + { + if ( [gesture isKindOfClass:[__LongPressGestureRecognizer class]] ) + { + pressGesture = (__LongPressGestureRecognizer *)gesture; + } + } + + if ( nil == pressGesture ) + { + pressGesture = [[[__LongPressGestureRecognizer alloc] initWithTarget:self action:@selector(didLongPress:)] autorelease]; + [self addGestureRecognizer:pressGesture]; + } + + return pressGesture; +} + +- (void)didLongPress:(UILongPressGestureRecognizer *)pressGesture +{ + if ( UIGestureRecognizerStateBegan == pressGesture.state ) + { + [self sendUISignal:UIView.HOLD_START]; + } + else if ( UIGestureRecognizerStateEnded == pressGesture.state ) + { + [self sendUISignal:UIView.HOLD_STOP]; + } + else if ( UIGestureRecognizerStateCancelled == pressGesture.state ) + { + [self sendUISignal:UIView.HOLD_CANCELLED]; + } +} + +- (BOOL)holdable +{ + return self.holdEnabled; +} + +- (void)setHoldable:(BOOL)flag +{ + self.holdEnabled = flag; +} + +- (BOOL)holdEnabled +{ + __LongPressGestureRecognizer * pressGesture = [self getLongPressGesture]; + if ( pressGesture ) + { + return pressGesture.enabled; + } + + return NO; +} + +- (void)setHoldEnabled:(BOOL)flag +{ + __LongPressGestureRecognizer * pressGesture = [self getLongPressGesture]; + if ( pressGesture ) + { + pressGesture.enabled = flag; + } +} + +- (UILongPressGestureRecognizer *)holdGesture +{ + return [self getLongPressGesture]; +} + +@end diff --git a/BeeFramework/MVC/View/Extension/UIView+PanGesture.h b/BeeFramework/MVC/View/Extension/UIView+PanGesture.h new file mode 100644 index 0000000..8f733b2 --- /dev/null +++ b/BeeFramework/MVC/View/Extension/UIView+PanGesture.h @@ -0,0 +1,50 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// UIView+PanGesture.h +// + +#import "Bee_Precompile.h" +#import "Bee_UISignal.h" + +#pragma mark - + +@interface UIView(PanGesture) + +AS_SIGNAL( PAN_START ) // 左右滑动开始 +AS_SIGNAL( PAN_STOP ) // 左右滑动结束 +AS_SIGNAL( PAN_CHANGED ) // 左右滑动位置变化 +AS_SIGNAL( PAN_CANCELLED ) // 左右滑动取消 + +@property (nonatomic, assign) BOOL pannable; // same as panEnabled +@property (nonatomic, assign) BOOL panEnabled; +@property (nonatomic, readonly) CGPoint panOffset; +@property (nonatomic, readonly) UIPanGestureRecognizer * panGesture; + +@end diff --git a/BeeFramework/MVC/View/Extension/UIView+PanGesture.m b/BeeFramework/MVC/View/Extension/UIView+PanGesture.m new file mode 100644 index 0000000..f4c020f --- /dev/null +++ b/BeeFramework/MVC/View/Extension/UIView+PanGesture.m @@ -0,0 +1,162 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// UIView+PanGesture.m +// + +#import "Bee_Precompile.h" +#import "Bee_UISignal.h" +#import "Bee_Singleton.h" +#import "Bee_Log.h" +#import "Bee_Performance.h" +#import "UIView+BeeExtension.h" +#import "UIView+PanGesture.h" +#import "UIView+BeeUISignal.h" + +#import + +#pragma mark - + +@interface __PanGestureRecognizer : UIPanGestureRecognizer +@end +@implementation __PanGestureRecognizer +@end + +#pragma mark - + +@interface UIView(PanGesturePrivate) +- (__PanGestureRecognizer *)getPanGesture; +- (void)didPan:(UIPanGestureRecognizer *)panGesture; +@end + +#pragma mark - + +@implementation UIView(PanGesture) + +DEF_SIGNAL( PAN_START ) +DEF_SIGNAL( PAN_STOP ) +DEF_SIGNAL( PAN_CHANGED ) +DEF_SIGNAL( PAN_CANCELLED ) + +@dynamic pannable; +@dynamic panEnabled; +@dynamic panOffset; +@dynamic panGesture; + +- (__PanGestureRecognizer *)getPanGesture +{ + __PanGestureRecognizer * panGesture = nil; + + for ( UIGestureRecognizer * gesture in self.gestureRecognizers ) + { + if ( [gesture isKindOfClass:[__PanGestureRecognizer class]] ) + { + panGesture = (__PanGestureRecognizer *)gesture; + } + } + + if ( nil == panGesture ) + { + panGesture = [[[__PanGestureRecognizer alloc] initWithTarget:self action:@selector(didPan:)] autorelease]; + [self addGestureRecognizer:panGesture]; + } + + return panGesture; +} + +- (void)didPan:(UIPanGestureRecognizer *)panGesture +{ + CGPoint panOffset = [panGesture translationInView:self]; + CC( @"panOffset = (%.0f, %.0f)", panOffset.x, panOffset.y ); + + if ( UIGestureRecognizerStateBegan == panGesture.state ) + { + [self sendUISignal:UIView.PAN_START]; + } + else if ( UIGestureRecognizerStateChanged == panGesture.state ) + { + [self sendUISignal:UIView.PAN_CHANGED]; + } + else if ( UIGestureRecognizerStateEnded == panGesture.state ) + { + [self sendUISignal:UIView.PAN_STOP]; + } + else if ( UIGestureRecognizerStateCancelled == panGesture.state ) + { + [self sendUISignal:UIView.PAN_CANCELLED]; + } +} + +- (BOOL)pannable +{ + return self.panEnabled; +} + +- (void)setPannable:(BOOL)flag +{ + self.panEnabled = flag; +} + +- (BOOL)panEnabled +{ + __PanGestureRecognizer * panGesture = [self getPanGesture]; + if ( panGesture ) + { + return panGesture.enabled; + } + + return NO; +} + +- (void)setPanEnabled:(BOOL)flag +{ + __PanGestureRecognizer * panGesture = [self getPanGesture]; + if ( panGesture ) + { + panGesture.enabled = flag; + } +} + +- (CGPoint)panOffset +{ + __PanGestureRecognizer * panGesture = [self getPanGesture]; + if ( panGesture ) + { + return [panGesture translationInView:self]; + } + + return CGPointZero; +} + +- (UIPanGestureRecognizer *)panGesture +{ + return [self getPanGesture]; +} + +@end diff --git a/BeeFramework/MVC/View/Extension/UIView+SwipeGesture.h b/BeeFramework/MVC/View/Extension/UIView+SwipeGesture.h new file mode 100644 index 0000000..c53da07 --- /dev/null +++ b/BeeFramework/MVC/View/Extension/UIView+SwipeGesture.h @@ -0,0 +1,50 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// UIView+SwipeGesture.h +// + +#import "Bee_Precompile.h" +#import "Bee_UISignal.h" + +#pragma mark - + +@interface UIView(SwipeGesture) + +AS_SIGNAL( SWIPE_UP ) // 瞬间向上滑动 +AS_SIGNAL( SWIPE_DOWN ) // 瞬间向下滑动 +AS_SIGNAL( SWIPE_LEFT ) // 瞬间向左滑动 +AS_SIGNAL( SWIPE_RIGHT ) // 瞬间向右滑动 + +@property (nonatomic, assign) BOOL swipeble; // same as swipeEnabled +@property (nonatomic, assign) BOOL swipeEnabled; +@property (nonatomic, assign) UISwipeGestureRecognizerDirection swipeDirection; +@property (nonatomic, readonly) UISwipeGestureRecognizer * swipeGesture; + +@end diff --git a/BeeFramework/MVC/View/Extension/UIView+SwipeGesture.m b/BeeFramework/MVC/View/Extension/UIView+SwipeGesture.m new file mode 100644 index 0000000..fd090dd --- /dev/null +++ b/BeeFramework/MVC/View/Extension/UIView+SwipeGesture.m @@ -0,0 +1,180 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_UISignal.m +// + +#import "Bee_Precompile.h" +#import "Bee_UISignal.h" +#import "Bee_Singleton.h" +#import "Bee_Log.h" +#import "Bee_Performance.h" +#import "UIView+BeeExtension.h" +#import "UIView+BeeUISignal.h" +#import "UIView+SwipeGesture.h" + +#import + +#pragma mark - + +@interface __SwipeGestureRecognizer : UISwipeGestureRecognizer +@end +@implementation __SwipeGestureRecognizer +@end + +#pragma mark - + +@interface UIView(SwipeGesturePrivate) +- (__SwipeGestureRecognizer *)getSwipeGesture; +- (void)didSwipe:(UISwipeGestureRecognizer *)swipeGesture; +@end + +#pragma mark - + +@implementation UIView(SwipeGesture) + +DEF_SIGNAL( SWIPE_UP ) +DEF_SIGNAL( SWIPE_DOWN ) +DEF_SIGNAL( SWIPE_LEFT ) +DEF_SIGNAL( SWIPE_RIGHT ) + +@dynamic swipeble; +@dynamic swipeEnabled; +@dynamic swipeDirection; +@dynamic swipeGesture; + +- (__SwipeGestureRecognizer *)getSwipeGesture +{ + __SwipeGestureRecognizer * swipeGesture = nil; + + for ( UIGestureRecognizer * gesture in self.gestureRecognizers ) + { + if ( [gesture isKindOfClass:[__SwipeGestureRecognizer class]] ) + { + swipeGesture = (__SwipeGestureRecognizer *)gesture; + } + } + + if ( nil == swipeGesture ) + { + swipeGesture = [[[__SwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipe:)] autorelease]; + swipeGesture.numberOfTouchesRequired = 1; + [self addGestureRecognizer:swipeGesture]; + } + + return swipeGesture; +} + +- (void)didSwipe:(UISwipeGestureRecognizer *)swipeGesture +{ + if ( UIGestureRecognizerStateEnded == swipeGesture.state ) + { + if ( UISwipeGestureRecognizerDirectionUp == swipeGesture.direction ) + { + CC( @"swipe up" ); + + [self sendUISignal:UIView.SWIPE_UP]; + } + else if ( UISwipeGestureRecognizerDirectionDown == swipeGesture.direction ) + { + CC( @"swipe down" ); + + [self sendUISignal:UIView.SWIPE_DOWN]; + } + else if ( UISwipeGestureRecognizerDirectionLeft == swipeGesture.direction ) + { + CC( @"swipe left" ); + + [self sendUISignal:UIView.SWIPE_LEFT]; + } + else if ( UISwipeGestureRecognizerDirectionRight == swipeGesture.direction ) + { + CC( @"swipe right" ); + + [self sendUISignal:UIView.SWIPE_RIGHT]; + } + } +} + +- (BOOL)swipeble +{ + return self.swipeEnabled; +} + +- (void)setSwipeble:(BOOL)flag +{ + self.swipeEnabled = flag; +} + +- (BOOL)swipeEnabled +{ + __SwipeGestureRecognizer * swipeGesture = [self getSwipeGesture]; + if ( swipeGesture ) + { + return swipeGesture.enabled; + } + + return NO; +} + +- (void)setSwipeEnabled:(BOOL)flag +{ + __SwipeGestureRecognizer * swipeGesture = [self getSwipeGesture]; + if ( swipeGesture ) + { + swipeGesture.enabled = flag; + } +} + +- (UISwipeGestureRecognizerDirection)direction +{ + __SwipeGestureRecognizer * swipeGesture = [self getSwipeGesture]; + if ( swipeGesture ) + { + return swipeGesture.direction; + } + + return 0; +} + +- (void)setSwipeDirection:(UISwipeGestureRecognizerDirection)direction +{ + __SwipeGestureRecognizer * swipeGesture = [self getSwipeGesture]; + if ( swipeGesture ) + { + swipeGesture.direction = direction; + } +} + +- (UISwipeGestureRecognizer *)swipeGesture +{ + return [self getSwipeGesture]; +} + +@end diff --git a/BeeFramework/MVC/View/Extension/UIView+TapGesture.h b/BeeFramework/MVC/View/Extension/UIView+TapGesture.h new file mode 100644 index 0000000..c6cbc8c --- /dev/null +++ b/BeeFramework/MVC/View/Extension/UIView+TapGesture.h @@ -0,0 +1,53 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// UIView+TapGesture.h +// + +#import "Bee_Precompile.h" +#import "Bee_UISignal.h" + +#pragma mark - + +@interface UIView(TapGesture) + +@property (nonatomic, assign) BOOL tappable; // same as tapEnabled +@property (nonatomic, assign) BOOL tapEnabled; +@property (nonatomic, retain) NSString * tapSignal; +@property (nonatomic, retain) NSObject * tapObject; +@property (nonatomic, readonly) UITapGestureRecognizer * tapGesture; + +AS_SIGNAL( TAPPED ); // 单击 + +- (void)makeTappable; +- (void)makeTappable:(NSString *)signal; +- (void)makeTappable:(NSString *)signal withObject:(NSObject *)obj; +- (void)makeUntappable; + +@end diff --git a/BeeFramework/MVC/View/Extension/UIView+TapGesture.m b/BeeFramework/MVC/View/Extension/UIView+TapGesture.m new file mode 100644 index 0000000..93037b6 --- /dev/null +++ b/BeeFramework/MVC/View/Extension/UIView+TapGesture.m @@ -0,0 +1,262 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_UISignal.m +// + +#import "Bee_Precompile.h" +#import "Bee_UISignal.h" +#import "Bee_Singleton.h" +#import "Bee_Log.h" +#import "Bee_Performance.h" +#import "UIView+BeeExtension.h" +#import "UIView+BeeUISignal.h" +#import "UIView+TapGesture.h" + +#import + +#pragma mark - + +@interface __SingleTapGestureRecognizer : UITapGestureRecognizer +{ + NSString * _signalName; + NSObject * _signalObject; +} + +@property (nonatomic, retain) NSString * signalName; +@property (nonatomic, assign) NSObject * signalObject; + +@end + +#pragma mark - + +@implementation __SingleTapGestureRecognizer + +@synthesize signalName = _signalName; +@synthesize signalObject = _signalObject; + +- (id)initWithTarget:(id)target action:(SEL)action +{ + self = [super initWithTarget:target action:action]; + if ( self ) + { + self.numberOfTapsRequired = 1; + self.numberOfTouchesRequired = 1; + self.cancelsTouchesInView = YES; + self.delaysTouchesBegan = YES; + self.delaysTouchesEnded = YES; + } + return self; +} + +- (void)dealloc +{ + [super dealloc]; +} + +@end + +#pragma mark - + +@interface UIView(TapGesturePrivate) +- (__SingleTapGestureRecognizer *)getTapGesture; +@end + +#pragma mark - + +@implementation UIView(TapGesture) + +DEF_SIGNAL( TAPPED ); + +@dynamic tappable; +@dynamic tapEnabled; +@dynamic tapGesture; +@dynamic tapSignal; +@dynamic tapObject; + +- (__SingleTapGestureRecognizer *)getTapGesture +{ + __SingleTapGestureRecognizer * tapGesture = nil; + + for ( UIGestureRecognizer * gesture in self.gestureRecognizers ) + { + if ( [gesture isKindOfClass:[__SingleTapGestureRecognizer class]] ) + { + tapGesture = (__SingleTapGestureRecognizer *)gesture; + } + } + + if ( nil == tapGesture ) + { + tapGesture = [[[__SingleTapGestureRecognizer alloc] initWithTarget:self action:@selector(didSingleTapped:)] autorelease]; + [self addGestureRecognizer:tapGesture]; + } + + return tapGesture; +} + +- (void)didSingleTapped:(UITapGestureRecognizer *)tapGesture +{ + if ( [tapGesture isKindOfClass:[__SingleTapGestureRecognizer class]] ) + { + __SingleTapGestureRecognizer * singleTapGesture = (__SingleTapGestureRecognizer *)tapGesture; + + if ( UIGestureRecognizerStateEnded == singleTapGesture.state ) + { + if ( singleTapGesture.signalName ) + { + [self sendUISignal:singleTapGesture.signalName withObject:singleTapGesture.signalObject]; + } + else + { + [self sendUISignal:UIView.TAPPED]; + } + } + } +} + +- (void)makeTappable +{ + [self makeTappable:nil]; +} + +- (void)makeTappable:(NSString *)signal +{ + [self makeTappable:signal withObject:nil]; +} + +- (void)makeTappable:(NSString *)signal withObject:(NSObject *)obj +{ + self.userInteractionEnabled = YES; + + __SingleTapGestureRecognizer * singleTapGesture = [self getTapGesture]; + if ( singleTapGesture ) + { + singleTapGesture.signalName = signal; + singleTapGesture.signalObject = obj; + } +} + +- (void)makeUntappable +{ + for ( UIGestureRecognizer * gesture in self.gestureRecognizers ) + { + if ( [gesture isKindOfClass:[__SingleTapGestureRecognizer class]] ) + { + [self removeGestureRecognizer:gesture]; + } + } +} + +- (BOOL)tappable +{ + return self.tapEnabled; +} + +- (void)setTappable:(BOOL)flag +{ + self.tapEnabled = flag; +} + +- (BOOL)tapEnabled +{ + for ( UIGestureRecognizer * gesture in self.gestureRecognizers ) + { + if ( [gesture isKindOfClass:[__SingleTapGestureRecognizer class]] ) + { + return gesture.enabled; + } + } + + return NO; +} + +- (void)setTapEnabled:(BOOL)flag +{ + __SingleTapGestureRecognizer * singleTapGesture = [self getTapGesture]; + if ( singleTapGesture ) + { + singleTapGesture.enabled = flag; + } +} + +- (UITapGestureRecognizer *)tapGesture +{ + for ( UIGestureRecognizer * gesture in self.gestureRecognizers ) + { + if ( [gesture isKindOfClass:[__SingleTapGestureRecognizer class]] ) + { + return (UITapGestureRecognizer *)gesture; + } + } + + return nil; +} + +- (NSString *)tapSignal +{ + __SingleTapGestureRecognizer * singleTapGesture = [self getTapGesture]; + if ( singleTapGesture ) + { + return singleTapGesture.signalName; + } + + return nil; +} + +- (void)setTapSignal:(NSString *)signal +{ + __SingleTapGestureRecognizer * singleTapGesture = [self getTapGesture]; + if ( singleTapGesture ) + { + singleTapGesture.signalName = signal; + } +} + +- (NSObject *)tapObject +{ + __SingleTapGestureRecognizer * singleTapGesture = [self getTapGesture]; + if ( singleTapGesture ) + { + return singleTapGesture.signalObject; + } + + return nil; +} + +- (void)setTapObject:(NSObject *)object +{ + __SingleTapGestureRecognizer * singleTapGesture = [self getTapGesture]; + if ( singleTapGesture ) + { + singleTapGesture.signalObject = object; + } +} + +@end diff --git a/BeeFramework/MVC/View/UIView+BeeWireframe.m b/BeeFramework/MVC/View/UIView+BeeWireframe.m deleted file mode 100644 index 9747d7a..0000000 --- a/BeeFramework/MVC/View/UIView+BeeWireframe.m +++ /dev/null @@ -1,227 +0,0 @@ -// -// ______ ______ ______ -// /\ __ \ /\ ___\ /\ ___\ -// \ \ __< \ \ __\_ \ \ __\_ -// \ \_____\ \ \_____\ \ \_____\ -// \/_____/ \/_____/ \/_____/ -// -// Copyright (c) 2012 BEE creators -// http://www.whatsbug.com -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -// IN THE SOFTWARE. -// -// -// UIView+BeeWireframe.m -// - -#import "Bee_Precompile.h" -#import "Bee_UISignal.h" -#import "Bee_UIImageView.h" -#import "Bee_UILabel.h" -#import "UIView+BeeWireframe.h" -#import "UIView+BeeQuery.h" - -#pragma mark - - -@interface BeeTintView : UIView -{ - BeeUILabel * _label; -} - -@property (nonatomic, readonly) BeeUILabel * label; - -@end - -#pragma mark - - -@implementation BeeTintView - -@synthesize label = _label; - -- (id)initWithFrame:(CGRect)frame -{ - self = [super initWithFrame:frame]; - if ( self ) - { - self.alpha = 0.6f; - self.backgroundColor = [UIColor grayColor]; - self.userInteractionEnabled = NO; - - _label = [[BeeUILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, frame.size.width, frame.size.height)]; - _label.textColor = [UIColor whiteColor]; - _label.textAlignment = UITextAlignmentCenter; - _label.font = [UIFont boldSystemFontOfSize:24.0f]; - _label.lineBreakMode = UILineBreakModeClip; - _label.numberOfLines = 1; - [self addSubview:_label]; - } - return self; -} - -- (void)setFrame:(CGRect)frame -{ - [super setFrame:frame]; - - _label.frame = CGRectMake( 0.0f, 0.0f, frame.size.width, frame.size.height ); -} - -- (void)drawRect:(CGRect)rect -{ - [super drawRect:rect]; - - CGContextRef context = UIGraphicsGetCurrentContext(); - if ( context ) - { - CGContextSaveGState( context ); - - CGContextSetStrokeColorWithColor( context, [UIColor colorWithWhite:0.3f alpha:1.0f].CGColor ); - CGContextMoveToPoint( context, 0.0f, 0.0f ); - CGContextAddLineToPoint( context, self.bounds.size.width, self.bounds.size.height ); - CGContextStrokePath( context ); - - CGContextSetStrokeColorWithColor( context, [UIColor colorWithWhite:0.3f alpha:1.0f].CGColor ); - CGContextMoveToPoint( context, 0.0f, self.bounds.size.height ); - CGContextAddLineToPoint( context, self.bounds.size.width, 0.0f ); - CGContextStrokePath( context ); - - CGContextRestoreGState( context ); - } -} - -- (void)dealloc -{ - SAFE_RELEASE_SUBVIEW( _label ); - - [super dealloc]; -} - -@end - -#pragma mark - - -@implementation UIView(BeeWireframe) - -@dynamic wireFrameTitle; -@dynamic wireFrameColor; - -- (BeeTintView *)__tintView -{ - BeeTintView * result = nil; - - for ( UIView * subView in self.subviews ) - { - if ( [subView isKindOfClass:[BeeTintView class]] ) - { - result = (BeeTintView *)subView; - break; - } - } - - return result; -} - -- (UIColor *)wireFrameColor -{ - return [self __tintView].backgroundColor; -} - -- (void)setWireFrameColor:(UIColor *)color -{ - [self showWireframe]; - - [self __tintView].backgroundColor = color; -} - -- (NSString *)wireFrameTitle -{ - return [self __tintView].label.text; -} - -- (void)setWireFrameTitle:(NSString *)title -{ - [self showWireframe]; - - [self __tintView].label.text = title; -} - -- (void)showWireframe -{ - [self showWireframe:nil tintColor:nil]; -} - -- (void)showWireframe:(NSString *)title -{ - [self showWireframe:title tintColor:nil]; -} - -- (void)showWireframe:(NSString *)title tintColor:(UIColor *)color -{ - BeeTintView * tintView = [self __tintView]; - if ( nil == tintView ) - { - tintView = [[[BeeTintView alloc] initWithFrame:self.bounds] autorelease]; - [self addSubview:tintView]; - [self sendSubviewToBack:tintView]; - - [self addObserver:self - forKeyPath:@"frame" - options:0 - context:nil]; - } - - if ( title ) - { - tintView.label.text = title; - } - - if ( color ) - { - tintView.backgroundColor = color; - } - - tintView.frame = self.bounds; - [tintView setNeedsDisplay]; -} - -- (void)hideWireframe -{ - BeeTintView * tintView = [self __tintView]; - if ( tintView ) - { - [tintView removeFromSuperview]; - } -} - -- (void)observeValueForKeyPath:(NSString *)keyPath - ofObject:(id)object - change:(NSDictionary *)change - context:(void *)context -{ - if ( [keyPath isEqualToString:@"frame"] ) - { - BeeTintView * tintView = [self __tintView]; - if ( tintView ) - { - tintView.frame = self.bounds; - [tintView setNeedsDisplay]; - } - } -} - -@end diff --git a/BeeFramework/MVC/ViewController/Bee_UIBoard.h b/BeeFramework/MVC/ViewController/Bee_UIBoard.h index 3c2ac3e..2d4c92c 100644 --- a/BeeFramework/MVC/ViewController/Bee_UIBoard.h +++ b/BeeFramework/MVC/ViewController/Bee_UIBoard.h @@ -42,31 +42,17 @@ @class BeeUIBoard; @class BeeUIStack; @class BeeUIStackGroup; -@class BeeUIMetrics; #pragma mark - @interface UIView(BeeUIBoard) - (BeeUIBoard *)board; -- (UIViewController *)viewController; -@end - -#pragma mark - - -@interface UIViewController(BeeExtension) -- (CGRect)viewFrame; -- (CGRect)viewBound; -- (CGSize)viewSize; -- (CGRect)screenBound; @end #pragma mark - @interface BeeUIBoard : UIViewController { - UIPopoverController * _popover; - NSInteger _stackAnimationType; - NSTimeInterval _lastSleep; NSTimeInterval _lastWeekup; BeeUIBoard * _parentBoard; @@ -76,20 +62,14 @@ BOOL _viewBuilt; BOOL _dataLoaded; NSInteger _state; - NSDate * _createDate; + BeeUIBoard * _modalBoard; UIButton * _modalMaskView; UIView * _modalContentView; - BeeUIBoard * _modalBoard; NSInteger _modalAnimationType; - - BOOL _panEnabled; - UIPanGestureRecognizer * _panGesture; - CGPoint _panOffset; - - BOOL _swipeEnabled; - UISwipeGestureRecognizer * _swipeGesture; + NSInteger _stackAnimationType; + UIPopoverController * _containedPopover; UIInterfaceOrientation _allowedOrientation; @@ -101,9 +81,6 @@ #endif // #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ } -@property (nonatomic, assign) UIPopoverController * popover; -@property (nonatomic, assign) NSInteger stackAnimationType; - @property (nonatomic, assign) NSTimeInterval lastSleep; @property (nonatomic, assign) NSTimeInterval lastWeekup; @property (nonatomic, assign) BeeUIBoard * parentBoard; @@ -113,20 +90,15 @@ @property (nonatomic, assign) BOOL viewBuilt; @property (nonatomic, assign) BOOL dataLoaded; @property (nonatomic, assign) NSInteger state; - @property (nonatomic, retain) NSDate * createDate; +@property (nonatomic, assign) UIPopoverController * containedPopover; +@property (nonatomic, assign) NSInteger stackAnimationType; + +@property (nonatomic, retain) BeeUIBoard * modalBoard; @property (nonatomic, retain) UIButton * modalMaskView; @property (nonatomic, retain) UIView * modalContentView; -@property (nonatomic, retain) BeeUIBoard * modalBoard; - -@property (nonatomic, assign) BOOL panEnabled; -@property (nonatomic, retain) UIPanGestureRecognizer * panGesture; -@property (nonatomic, assign) CGPoint panOffset; - -@property (nonatomic, assign) BOOL swipeEnabled; -@property (nonatomic, assign) UISwipeGestureRecognizerDirection swipeDirection; -@property (nonatomic, retain) UISwipeGestureRecognizer * swipeGesture; +@property (nonatomic, assign) NSInteger modalAnimationType; @property (nonatomic, readonly) BOOL deactivated; @property (nonatomic, readonly) BOOL deactivating; @@ -139,9 +111,6 @@ @property (nonatomic, readonly) BeeUIBoard * previousBoard; @property (nonatomic, readonly) BeeUIBoard * nextBoard; -@property (nonatomic, assign) NSString * titleString; -@property (nonatomic, assign) UIView * titleView; - @property (nonatomic, assign) UIInterfaceOrientation allowedOrientation; #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ @@ -172,42 +141,21 @@ AS_SIGNAL( POPOVER_DID_PRESENT ) // Popover已经显示 AS_SIGNAL( POPOVER_WILL_DISMISS ) // Popover将要隐藏 AS_SIGNAL( POPOVER_DID_DISMISSED ) // Popover已经隐藏 -AS_SIGNAL( BACK_BUTTON_TOUCHED ) // NavigationBar左按钮被点击 -AS_SIGNAL( DONE_BUTTON_TOUCHED ) // NavigationBar右按钮被点击 - -AS_SIGNAL( PAN_START ) // 手势:左右滑动开始 -AS_SIGNAL( PAN_STOP ) // 手势:左右滑动结束 -AS_SIGNAL( PAN_CHANGED ) // 手势:左右滑动位置变化 -AS_SIGNAL( PAN_CANCELLED ) // 手势:左右滑动取消 - -AS_SIGNAL( SWIPE_UP ) // 手势:瞬间向上滑动 -AS_SIGNAL( SWIPE_DOWN ) // 手势:瞬间向下滑动 -AS_SIGNAL( SWIPE_LEFT ) // 手势:瞬间向左滑动 -AS_SIGNAL( SWIPE_RIGHT ) // 手势:瞬间向右滑动 - - AS_INT( STATE_DEACTIVATED ) // 隐藏 AS_INT( STATE_DEACTIVATING ) // 将要隐藏 AS_INT( STATE_ACTIVATING ) // 将要显示 AS_INT( STATE_ACTIVATED ) // 显示 -AS_INT( BARBUTTON_LEFT ) // 左按钮 -AS_INT( BARBUTTON_RIGHT ) // 右按钮 - AS_INT( ANIMATION_TYPE_ALPHA ) // 渐隐动画 AS_INT( ANIMATION_TYPE_BOUNCE ) // 跳动动画 AS_INT( ANIMATION_TYPE_DEFAULT ) // 默认动画 - + (NSArray *)allBoards; + (BeeUIBoard *)board; - (void)load; - (void)unload; -- (void)showNavigationBarAnimated:(BOOL)animated; -- (void)hideNavigationBarAnimated:(BOOL)animated; - - (void)presentModalView:(UIView *)view animated:(BOOL)animated; - (void)presentModalView:(UIView *)view animated:(BOOL)animated animationType:(NSInteger)type; - (void)dismissModalViewAnimated:(BOOL)animated; @@ -221,12 +169,6 @@ AS_INT( ANIMATION_TYPE_DEFAULT ) // 默认动画 - (void)presentModalBoard:(BeeUIBoard *)board animated:(BOOL)animated; - (void)dismissModalBoardAnimated:(BOOL)animated; -- (void)showBarButton:(NSInteger)position title:(NSString *)name; -- (void)showBarButton:(NSInteger)position image:(UIImage *)image; -- (void)showBarButton:(NSInteger)position system:(UIBarButtonSystemItem)index; -- (void)showBarButton:(NSInteger)position custom:(UIView *)view; -- (void)hideBarButton:(NSInteger)position; - @end #pragma mark - diff --git a/BeeFramework/MVC/ViewController/Bee_UIBoard.m b/BeeFramework/MVC/ViewController/Bee_UIBoard.m index 94347c4..b8a3dc5 100644 --- a/BeeFramework/MVC/ViewController/Bee_UIBoard.m +++ b/BeeFramework/MVC/ViewController/Bee_UIBoard.m @@ -40,12 +40,17 @@ #import "Bee_Controller.h" #import "Bee_SystemInfo.h" -#import "UIView+BeeBackground.h" -#import "UIView+BeeQuery.h" +#import "NSObject+BeeMessage.h" +#import "NSObject+BeeRequest.h" + +#import "UIView+BeeExtension.h" #import "UIFont+BeeExtension.h" #import "NSObject+BeeNotification.h" #import "NSObject+BeeTicker.h" #import "NSArray+BeeExtension.h" +#import "UIViewController+BeeExtension.h" +#import "UIView+BeeUISignal.h" +#import "UIViewController+BeeUISignal.h" #pragma mark - @@ -64,7 +69,9 @@ @interface BeeUIBoardView : UIView { BeeUIBoard * _owner; } + @property (nonatomic, assign) BeeUIBoard * owner; + @end #pragma mark - @@ -74,9 +81,11 @@ @implementation UIView(BeeUIBoard) - (BeeUIBoard *)board { UIView * topView = self; + while ( topView.superview ) { topView = topView.superview; + if ( [topView isKindOfClass:[UIWindow class]] ) { break; @@ -88,6 +97,7 @@ - (BeeUIBoard *)board } UIViewController * controller = [topView viewController]; + if ( controller && [controller isKindOfClass:[BeeUIBoard class]] ) { return (BeeUIBoard *)controller; @@ -98,74 +108,12 @@ - (BeeUIBoard *)board } } -- (UIViewController *)viewController -{ - id nextResponder = [self nextResponder]; - if ( [nextResponder isKindOfClass:[UIViewController class]] ) - { - return (UIViewController *)nextResponder; - } - else - { - return nil; - } -} - -@end - -#pragma mark - - -@implementation UIViewController(BeeExtension) - -- (CGRect)viewFrame -{ - CGRect bounds = [UIScreen mainScreen].bounds; - -// UIInterfaceOrientation orient = [UIApplication sharedApplication].statusBarOrientation; -// CGRect applicationframe = [UIScreen mainScreen].applicationFrame; - - if ( UIInterfaceOrientationIsLandscape(self.interfaceOrientation) ) - { - bounds.origin = CGPointMake( bounds.origin.y, bounds.origin.x ); - bounds.size = CGSizeMake( bounds.size.height, bounds.size.width ); - } - - if ( NO == [UIApplication sharedApplication].statusBarHidden ) - { - bounds.origin.y += 20; - bounds.size.height -= 20; - } - - if ( NO == self.navigationController.navigationBarHidden ) - { - bounds.size.height -= self.navigationController.navigationBar.bounds.size.height; - } - - return bounds; -} - -- (CGRect)viewBound -{ - CGRect bound = self.viewFrame; - bound.origin = CGPointZero; - return bound; -} - -- (CGSize)viewSize -{ - return self.viewFrame.size; -} - -- (CGRect)screenBound -{ - return [UIScreen mainScreen].bounds; -} - @end #pragma mark - @interface BeeUIBoard(Private) + - (void)createViews; - (void)deleteViews; - (void)loadDatas; @@ -189,17 +137,6 @@ - (void)bounce2ForAppearingAnimationStopped; - (void)resignFirstResponderWalkThrough:(UIView *)rootView; - (void)becomeFirstResponderWalkThrough:(UIView *)rootView; -- (void)didLeftBarButtonTouched; -- (void)didRightBarButtonTouched; - -- (void)didPan:(UIPanGestureRecognizer *)panGesture; -- (void)enablePanGesture; -- (void)disablePanGesture; - -- (void)didSwipe:(UISwipeGestureRecognizer *)swipeGesture; -- (void)enableSwipeGesture; -- (void)disableSwipeGesture; - @end #pragma mark - @@ -209,27 +146,26 @@ @implementation BeeUIBoardView @synthesize owner = _owner; - (void)setFrame:(CGRect)rect -{ - CGRect prevFrame = self.frame; - - [super setFrame:rect]; - - [self fitBackgroundFrame]; - - if ( _owner && NO == CGRectEqualToRect(prevFrame, rect) ) - { - [_owner sendUISignal:BeeUIBoard.LAYOUT_VIEWS]; - } +{ +// if ( CGRectEqualToRect(rect, super.frame) ) +// { + [super setFrame:rect]; + + if ( _owner ) + { + [_owner sendUISignal:BeeUIBoard.LAYOUT_VIEWS]; + } +// } } - (void)layoutSubviews { [super layoutSubviews]; -// if ( _owner ) -// { -// [_owner sendUISignal:BeeUIBoard.LAYOUT_VIEWS]; -// } + if ( _owner ) + { + [_owner sendUISignal:BeeUIBoard.LAYOUT_VIEWS]; + } } - (void)dealloc @@ -260,7 +196,7 @@ - (void)handleUISignal:(BeeUISignal *)signal @implementation BeeUIBoard -@synthesize popover = _popover; +@synthesize containedPopover = _containedPopover; @synthesize stackAnimationType = _stackAnimationType; @synthesize lastSleep = _lastSleep; @@ -275,17 +211,10 @@ @implementation BeeUIBoard @synthesize createDate = _createDate; +@synthesize modalBoard = _modalBoard; @synthesize modalMaskView = _modalMaskView; @synthesize modalContentView = _modalContentView; -@synthesize modalBoard = _modalBoard; - -@synthesize panEnabled; -@synthesize panGesture = _panGesture; -@synthesize panOffset = _panOffset; - -@synthesize swipeEnabled; -@synthesize swipeDirection; -@synthesize swipeGesture = _swipeGesture; +@synthesize modalAnimationType = _modalAnimationType; @synthesize deactivated; @synthesize deactivating; @@ -298,9 +227,6 @@ @implementation BeeUIBoard @dynamic previousBoard; @dynamic nextBoard; -@synthesize titleString; -@synthesize titleView; - @synthesize allowedOrientation = _allowedOrientation; #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ @@ -331,27 +257,11 @@ @implementation BeeUIBoard DEF_SIGNAL( POPOVER_WILL_DISMISS ) // Popover将要隐藏 DEF_SIGNAL( POPOVER_DID_DISMISSED ) // Popover已经隐藏 -DEF_SIGNAL( BACK_BUTTON_TOUCHED ) // NavigationBar左按钮被点击 -DEF_SIGNAL( DONE_BUTTON_TOUCHED ) // NavigationBar右按钮被点击 - -DEF_SIGNAL( PAN_START ) // 左右滑动手势开始 -DEF_SIGNAL( PAN_STOP ) // 左右滑动手势结束 -DEF_SIGNAL( PAN_CHANGED ) // 左右滑动手势位置变化 -DEF_SIGNAL( PAN_CANCELLED ) // 左右滑动手势取消 - -DEF_SIGNAL( SWIPE_UP ) // 手势:瞬间向上滑动 -DEF_SIGNAL( SWIPE_DOWN ) // 手势:瞬间向下滑动 -DEF_SIGNAL( SWIPE_LEFT ) // 手势:瞬间向左滑动 -DEF_SIGNAL( SWIPE_RIGHT ) // 手势:瞬间向右滑动 - DEF_INT( STATE_DEACTIVATED, 0 ) DEF_INT( STATE_DEACTIVATING, 1 ) DEF_INT( STATE_ACTIVATING, 2 ) DEF_INT( STATE_ACTIVATED, 3 ) -DEF_INT( BARBUTTON_LEFT, 0 ) -DEF_INT( BARBUTTON_RIGHT, 1 ) - DEF_INT( ANIMATION_TYPE_DEFAULT, 0 ) DEF_INT( ANIMATION_TYPE_ALPHA, 0 ) DEF_INT( ANIMATION_TYPE_BOUNCE, 1 ) @@ -376,10 +286,10 @@ - (id)init { if ( nil == __allBoards ) { - __allBoards = [[NSMutableArray alloc] init]; + __allBoards = [NSMutableArray nonRetainingArray]; } - - [__allBoards insertObjectNoRetain:self atIndex:0]; + + [__allBoards insertObject:self atIndex:0]; _lastSleep = [NSDate timeIntervalSinceReferenceDate]; _lastWeekup = [NSDate timeIntervalSinceReferenceDate]; @@ -393,7 +303,7 @@ - (id)init _createDate = [[NSDate date] retain]; _modalAnimationType = BeeUIBoard.ANIMATION_TYPE_ALPHA; - _allowedOrientation = UIInterfaceOrientationPortrait; + _allowedOrientation = UIInterfaceOrientationPortrait|UIInterfaceOrientationPortraitUpsideDown|UIInterfaceOrientationLandscapeLeft|UIInterfaceOrientationLandscapeRight; #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ _createSeq = __createSeed++; @@ -440,8 +350,6 @@ - (void)dealloc #endif // #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ [_createDate release]; - [_panGesture release]; - [_swipeGesture release]; if ( _modalBoard.viewBuilt ) { @@ -452,7 +360,7 @@ - (void)dealloc [NSObject cancelPreviousPerformRequestsWithTarget:self]; - [__allBoards removeObjectNoRelease:self]; + [__allBoards removeObject:self]; [super dealloc]; } @@ -624,28 +532,56 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { - if ( NO == _viewBuilt ) + if ( _viewBuilt ) + { + [self sendUISignal:BeeUIBoard.LAYOUT_VIEWS]; + [self sendUISignal:BeeUIBoard.ORIENTATION_CHANGED]; + } +} + +- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation +{ + if ( _viewBuilt ) { -// [self sendUISignal:BeeUIBoard.CREATE_VIEWS]; [self sendUISignal:BeeUIBoard.LAYOUT_VIEWS]; [self sendUISignal:BeeUIBoard.ORIENTATION_CHANGED]; - - _viewBuilt = YES; } } #if defined(__IPHONE_6_0) + -(NSUInteger)supportedInterfaceOrientations { - if ( IOS6_OR_LATER ) + NSUInteger orientation = 0; + + if ( (_allowedOrientation & UIInterfaceOrientationPortrait) != 0 ) { - return UIInterfaceOrientationMaskPortrait; + orientation |= UIInterfaceOrientationMaskPortrait; } - else + + if ( (_allowedOrientation & UIInterfaceOrientationPortraitUpsideDown) != 0 ) { - return 0; + orientation |= UIInterfaceOrientationMaskPortraitUpsideDown; } + + if ( (_allowedOrientation & UIInterfaceOrientationLandscapeLeft) != 0 ) + { + orientation |= UIInterfaceOrientationMaskLandscapeLeft; + } + + if ( (_allowedOrientation & UIInterfaceOrientationLandscapeRight) != 0 ) + { + orientation |= UIInterfaceOrientationMaskLandscapeRight; + } + + return orientation; } + +- (BOOL)shouldAutorotate +{ + return YES; +} + #endif // #if defined(__IPHONE_6_0) - (void)didReceiveMemoryWarning @@ -850,48 +786,25 @@ - (void)handleUISignal:(BeeUISignal *)signal self.view.backgroundColor = [UIColor clearColor]; // self.navigationController.navigationBarHidden = YES; - _modalMaskView = [[UIButton alloc] initWithFrame:self.view.bounds]; + _modalMaskView = [[UIButton alloc] initWithFrame:self.viewBound]; _modalMaskView.hidden = YES; _modalMaskView.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.1f]; [_modalMaskView addTarget:self action:@selector(didModalMaskTouched) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:_modalMaskView]; - - if ( _panEnabled ) - { - [self enablePanGesture]; - } - - if ( _swipeEnabled ) - { - [self enableSwipeGesture]; - } } else if ( [signal is:BeeUIBoard.DELETE_VIEWS] ) { - [self disablePanGesture]; - [self disableSwipeGesture]; - SAFE_RELEASE_SUBVIEW( _modalMaskView ); SAFE_RELEASE_SUBVIEW( _modalContentView ); } else if ( [signal is:BeeUIBoard.LAYOUT_VIEWS] ) { - self.modalMaskView.frame = self.view.bounds; + self.modalMaskView.frame = self.viewBound; } else if ( [signal is:BeeUIBoard.WILL_APPEAR] ) { [self.view bringSubviewToFront:_modalMaskView]; [self.view bringSubviewToFront:_modalContentView]; - - if ( _panEnabled ) - { - [self enablePanGesture]; - } - - if ( _swipeEnabled ) - { - [self enableSwipeGesture]; - } } else if ( [signal is:BeeUIBoard.DID_APPEAR] ) { @@ -910,16 +823,6 @@ - (void)handleUISignal:(BeeUISignal *)signal } } -- (void)showNavigationBarAnimated:(BOOL)animated -{ - [self.navigationController setNavigationBarHidden:NO animated:animated]; -} - -- (void)hideNavigationBarAnimated:(BOOL)animated -{ - [self.navigationController setNavigationBarHidden:YES animated:animated]; -} - - (void)didModalMaskTouched { [self dismissModalViewAnimated:YES]; @@ -1115,15 +1018,9 @@ - (void)resignFirstResponderWalkThrough:(UIView *)rootView { for ( UIView * subview in rootView.subviews ) { - if ( [subview isKindOfClass:[UITextField class]] ) + if ( [subview respondsToSelector:@selector(resignFirstResponder)] ) { - UITextField * textField = (UITextField *)subview; - [textField resignFirstResponder]; - } - else if ( [subview isKindOfClass:[UITextView class]] ) - { - UITextView * textView = (UITextView *)subview; - [textView resignFirstResponder]; + [subview performSelector:@selector(resignFirstResponder)]; } else { @@ -1138,128 +1035,6 @@ - (BOOL)resignFirstResponder return YES; } -- (NSString *)titleString -{ - return self.navigationItem.title ? self.navigationItem.title : self.title; -} - -- (void)setTitleString:(NSString *)text -{ - self.navigationItem.title = text; -} - -- (UIView *)titleView -{ - return self.navigationItem.titleView; -} - -- (void)setTitleView:(UIView *)view -{ - self.navigationItem.titleView = view; -} - -- (void)didLeftBarButtonTouched -{ - [self sendUISignal:BeeUIBoard.BACK_BUTTON_TOUCHED]; -} - -- (void)didRightBarButtonTouched -{ - [self sendUISignal:BeeUIBoard.DONE_BUTTON_TOUCHED]; -} - -- (void)showBarButton:(NSInteger)position title:(NSString *)name -{ - if ( BeeUIBoard.BARBUTTON_LEFT == position ) - { - self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:name - style:UIBarButtonItemStylePlain - target:self - action:@selector(didLeftBarButtonTouched)] autorelease]; - } - else - { - self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:name - style:UIBarButtonItemStylePlain - target:self - action:@selector(didRightBarButtonTouched)] autorelease]; - } -} - -- (void)showBarButton:(NSInteger)position image:(UIImage *)image -{ - UIButton * button = [[[UIButton alloc] initWithFrame:CGRectMake(0, 0, image.size.width, image.size.height)] autorelease]; - button.contentMode = UIViewContentModeScaleAspectFit; - button.backgroundColor = [UIColor clearColor]; - [button setImage:image forState:UIControlStateNormal]; - - if ( BeeUIBoard.BARBUTTON_LEFT == position ) - { - [button addTarget:self action:@selector(didLeftBarButtonTouched) forControlEvents:UIControlEventTouchUpInside]; - self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:button] autorelease]; - } - else - { - [button addTarget:self action:@selector(didRightBarButtonTouched) forControlEvents:UIControlEventTouchUpInside]; - self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:button] autorelease]; - } - -// if ( BEE_UIBOARD_BARBUTTON_LEFT == position ) -// { -// self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithImage:image -// style:UIBarButtonItemStylePlain -// target:self -// action:@selector(didLeftBarButtonTouched)] autorelease]; -// } -// else -// { -// self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithImage:image -// style:UIBarButtonItemStylePlain -// target:self -// action:@selector(didRightBarButtonTouched)] autorelease]; -// } -} - -- (void)showBarButton:(NSInteger)position system:(UIBarButtonSystemItem)index -{ - if ( BeeUIBoard.BARBUTTON_LEFT == position ) - { - self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:index - target:self - action:@selector(didLeftBarButtonTouched)] autorelease]; - } - else - { - self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:index - target:self - action:@selector(didRightBarButtonTouched)] autorelease]; - } -} - -- (void)showBarButton:(NSInteger)position custom:(UIView *)view -{ - if ( BeeUIBoard.BARBUTTON_LEFT == position ) - { - self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:view] autorelease]; - } - else - { - self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:view] autorelease]; - } -} - -- (void)hideBarButton:(NSInteger)position -{ - if ( BeeUIBoard.BARBUTTON_LEFT == position ) - { - self.navigationItem.leftBarButtonItem = nil; - } - else - { - self.navigationItem.rightBarButtonItem = nil; - } -} - - (BOOL)deactivated { return BeeUIBoard.STATE_DEACTIVATED == _state ? YES : NO; @@ -1280,178 +1055,6 @@ - (BOOL)activated return BeeUIBoard.STATE_ACTIVATED == _state ? YES : NO; } -- (BOOL)panEnabled -{ - return _panEnabled; -} - -- (void)setPanEnabled:(BOOL)flag -{ - if ( flag == _panEnabled ) - return; - - if ( flag ) - { - [self enablePanGesture]; - } - else - { - [self disablePanGesture]; - } - - _panEnabled = flag; -} - -- (void)enablePanGesture -{ - if ( nil == _panGesture ) - { - _panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(didPan:)]; - _panGesture.delegate = self; - } - - if ( _viewBuilt ) - { - [self.view removeGestureRecognizer:_panGesture]; - [self.view addGestureRecognizer:_panGesture]; - } -} - -- (void)disablePanGesture -{ - if ( _panGesture ) - { - if ( _viewBuilt ) - { - [self.view removeGestureRecognizer:_panGesture]; - } - } -} - -- (void)didPan:(UIPanGestureRecognizer *)panGesture -{ - if ( NO == _panEnabled ) - return; - - _panOffset = [panGesture translationInView:self.view]; - - CC( @"panOffset = (%.0f, %.0f)", _panOffset.x, _panOffset.y ); - - if ( UIGestureRecognizerStateBegan == panGesture.state ) - { - [self sendUISignal:BeeUIBoard.PAN_START]; - } - else if ( UIGestureRecognizerStateChanged == panGesture.state ) - { - [self sendUISignal:BeeUIBoard.PAN_CHANGED]; - } - else if ( UIGestureRecognizerStateEnded == panGesture.state ) - { - [self sendUISignal:BeeUIBoard.PAN_STOP]; - - _panOffset = CGPointZero; - } - else if ( UIGestureRecognizerStateCancelled == panGesture.state ) - { - [self sendUISignal:BeeUIBoard.PAN_CANCELLED]; - - _panOffset = CGPointZero; - } -} - -- (BOOL)swipeEnabled -{ - return _swipeEnabled; -} - -- (void)setSwipeEnabled:(BOOL)flag -{ - if ( flag == _swipeEnabled ) - return; - - if ( flag ) - { - [self enableSwipeGesture]; - } - else - { - [self disableSwipeGesture]; - } - - _swipeEnabled = flag; -} - -- (UISwipeGestureRecognizerDirection)direction -{ - return _swipeGesture ? _swipeGesture.direction : 0; -} - -- (void)setSwipeDirection:(UISwipeGestureRecognizerDirection)direction -{ - _swipeGesture.direction = direction; -} - -- (void)enableSwipeGesture -{ - if ( nil == _swipeGesture ) - { - _swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipe:)]; - _swipeGesture.numberOfTouchesRequired = 1; - _swipeGesture.delegate = self; - } - - if ( _viewBuilt ) - { - [self.view removeGestureRecognizer:_swipeGesture]; - [self.view addGestureRecognizer:_swipeGesture]; - } -} - -- (void)disableSwipeGesture -{ - if ( _swipeGesture ) - { - if ( _viewBuilt ) - { - [self.view removeGestureRecognizer:_swipeGesture]; - } - } -} - -- (void)didSwipe:(UISwipeGestureRecognizer *)swipeGesture -{ - if ( NO == _swipeEnabled ) - return; - - if ( UIGestureRecognizerStateEnded == swipeGesture.state ) - { - if ( UISwipeGestureRecognizerDirectionUp == swipeGesture.direction ) - { - CC( @"swipe up" ); - - [self sendUISignal:BeeUIBoard.SWIPE_UP]; - } - else if ( UISwipeGestureRecognizerDirectionDown == swipeGesture.direction ) - { - CC( @"swipe down" ); - - [self sendUISignal:BeeUIBoard.SWIPE_DOWN]; - } - else if ( UISwipeGestureRecognizerDirectionLeft == swipeGesture.direction ) - { - CC( @"swipe left" ); - - [self sendUISignal:BeeUIBoard.SWIPE_LEFT]; - } - else if ( UISwipeGestureRecognizerDirectionRight == swipeGesture.direction ) - { - CC( @"swipe right" ); - - [self sendUISignal:BeeUIBoard.SWIPE_RIGHT]; - } - } -} - - (void)presentPopoverForView:(UIView *)view contentSize:(CGSize)size direction:(UIPopoverArrowDirection)direction @@ -1459,25 +1062,25 @@ - (void)presentPopoverForView:(UIView *)view { self.view.frame = CGRectMake( 0.0f, 0.0f, size.width, size.height ); - self.popover = [[[UIPopoverController alloc] initWithContentViewController:[BeeUIStack stackWithFirstBoard:self]] autorelease]; - self.popover.delegate = self; + self.containedPopover = [[[UIPopoverController alloc] initWithContentViewController:[BeeUIStack stackWithFirstBoard:self]] autorelease]; + self.containedPopover.delegate = self; self.contentSizeForViewInPopover = size; - [self.popover setPopoverContentSize:size]; - + [self.containedPopover setPopoverContentSize:size]; + [self sendUISignal:BeeUIBoard.POPOVER_WILL_PRESENT]; - - [self.popover presentPopoverFromRect:view.frame - inView:view.superview - permittedArrowDirections:direction - animated:animated]; + + [self.containedPopover presentPopoverFromRect:view.frame + inView:view.superview + permittedArrowDirections:direction + animated:animated]; [self sendUISignal:BeeUIBoard.POPOVER_DID_PRESENT]; } - (void)dismissPopoverAnimated:(BOOL)animated { - [self.popover dismissPopoverAnimated:animated]; - self.popover = nil; + [self.containedPopover dismissPopoverAnimated:animated]; + self.containedPopover = nil; } - (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController @@ -1489,7 +1092,7 @@ - (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverCont - (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController { [self sendUISignal:BeeUIBoard.POPOVER_DID_DISMISSED]; - self.popover = nil; + self.containedPopover = nil; } @end diff --git a/BeeFramework/MVC/ViewController/Bee_UIStack.h b/BeeFramework/MVC/ViewController/Bee_UIStack.h index 051df22..8da1388 100644 --- a/BeeFramework/MVC/ViewController/Bee_UIStack.h +++ b/BeeFramework/MVC/ViewController/Bee_UIStack.h @@ -53,9 +53,6 @@ { BeeUIBoard * _parentBoard; NSString * _name; - - NSMutableArray * _leftButtons; - NSMutableArray * _rightButtons; } AS_INT( ANIMATION_TYPE_DEFAULT ) // 默认 @@ -67,6 +64,7 @@ AS_INT( ANIMATION_TYPE_FLIP ) // 翻页 @property (nonatomic, retain) NSString * name; @property (nonatomic, assign) BeeUIBoard * parentBoard; + @property (nonatomic, readonly) NSArray * boards; @property (nonatomic, readonly) BeeUIBoard * topBoard; diff --git a/BeeFramework/MVC/ViewController/Bee_UIStack.m b/BeeFramework/MVC/ViewController/Bee_UIStack.m index 9dbf7d1..3d9f071 100644 --- a/BeeFramework/MVC/ViewController/Bee_UIStack.m +++ b/BeeFramework/MVC/ViewController/Bee_UIStack.m @@ -34,6 +34,7 @@ #import "Bee_UIBoard.h" #import "Bee_UIStack.h" #import "Bee_Runtime.h" +#import "UIView+BeeExtension.h" #pragma mark - @@ -251,7 +252,7 @@ - (void)pushBoard:(BeeUIBoard *)board animated:(BOOL)animated - (void)pushBoard:(BeeUIBoard *)newBoard animated:(BOOL)animated animationType:(NSInteger)type { - newBoard.popover = self.topBoard.popover; + newBoard.containedPopover = self.topBoard.containedPopover; newBoard.stackAnimationType = type; if ( NO == animated ) @@ -326,7 +327,7 @@ - (void)pushBoard:(BeeUIBoard *)newBoard animated:(BOOL)animated animationType:( [animation setRemovedOnCompletion:YES]; [self.view.layer removeAnimationForKey:@"slide_in"]; [self.view.layer addAnimation:animation forKey:@"slide_in"]; - + [super pushViewController:newBoard animated:NO]; } else if ( BeeUIStack.ANIMATION_TYPE_FLIP == type ) @@ -344,6 +345,9 @@ - (void)popBoardAnimated:(BOOL)animated - (void)popBoardAnimated:(BOOL)animated animationType:(NSInteger)animType { + if ( self.boards.count <= 1 ) + return; + if ( NO == animated ) { [super popViewControllerAnimated:NO]; @@ -411,8 +415,8 @@ - (void)popBoardAnimated:(BOOL)animated animationType:(NSInteger)animType else if ( BeeUIStack.ANIMATION_TYPE_SLIDE == animType ) { [super popViewControllerAnimated:NO]; - - CATransition *animation = [CATransition animation]; + + CATransition * animation = [CATransition animation]; [animation setDuration:0.6f]; [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]]; [animation setType:kCATransitionPush]; diff --git a/BeeFramework/MVC/ViewController/Bee_UIStackGroup.h b/BeeFramework/MVC/ViewController/Bee_UIStackGroup.h index eab63e4..850b8d1 100644 --- a/BeeFramework/MVC/ViewController/Bee_UIStackGroup.h +++ b/BeeFramework/MVC/ViewController/Bee_UIStackGroup.h @@ -38,6 +38,9 @@ @class BeeUIBoard; @class BeeUIStack; +@class BeeUIStackGroup; + +typedef BeeUIStackGroup BeeUINavigationControllerGroup; #pragma mark - @@ -47,8 +50,6 @@ NSMutableArray * _stacks; } -AS_SINGLETON( BeeUIStackGroup ); - AS_SIGNAL( INDEX_CHANGED ); // 显示顺序变了 @property (nonatomic, retain) NSMutableArray * stacks; diff --git a/BeeFramework/MVC/ViewController/Bee_UIStackGroup.m b/BeeFramework/MVC/ViewController/Bee_UIStackGroup.m index eafc36b..2267919 100644 --- a/BeeFramework/MVC/ViewController/Bee_UIStackGroup.m +++ b/BeeFramework/MVC/ViewController/Bee_UIStackGroup.m @@ -41,20 +41,12 @@ #pragma mark - -@interface BeeUIStackGroup(Private) -- (void)arrange; -@end - -#pragma mark - - @implementation BeeUIStackGroup @synthesize stacks = _stacks; @synthesize topIndex; @synthesize topStack; -DEF_SINGLETON(BeeUIStackGroup) - DEF_SIGNAL( INDEX_CHANGED ); + (BeeUIStackGroup *)stackGroup diff --git a/BeeFramework/MVC/ViewController/Bee_ViewController.h b/BeeFramework/MVC/ViewController/Bee_ViewController.h new file mode 100644 index 0000000..986b863 --- /dev/null +++ b/BeeFramework/MVC/ViewController/Bee_ViewController.h @@ -0,0 +1,41 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_ViewController.h +// + +#import "UIViewController+BeeExtension.h" + +#import "Bee_UIBoard.h" +#import "Bee_UIStack.h" +#import "Bee_UIStackGroup.h" + +#import "UIViewController+BeeExtension.h" +#import "UIViewController+BeeUISignal.h" +#import "UIViewController+UINavigationBar.h" diff --git a/BeeFramework/MVC/ViewController/Bee_ViewController.m b/BeeFramework/MVC/ViewController/Bee_ViewController.m new file mode 100644 index 0000000..7c20afe --- /dev/null +++ b/BeeFramework/MVC/ViewController/Bee_ViewController.m @@ -0,0 +1,33 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_ViewController.h +// + +#import "Bee_ViewController.h" diff --git a/BeeFramework/MVC/ViewController/Extension/UIViewController+BeeExtension.h b/BeeFramework/MVC/ViewController/Extension/UIViewController+BeeExtension.h new file mode 100644 index 0000000..86d10ea --- /dev/null +++ b/BeeFramework/MVC/ViewController/Extension/UIViewController+BeeExtension.h @@ -0,0 +1,51 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// UIView+BeeExtension.h +// + +#import "Bee_Precompile.h" + +#pragma mark - + +@interface UIViewController(BeeExtension) + +@property (nonatomic, retain) NSString * titleString; +@property (nonatomic, retain) UIView * titleView; + +- (UIView *)viewIfLoaded; +- (UIView *)viewWithTagString:(NSString *)value; +- (UIView *)viewAtPath:(NSString *)name; +- (UIView *)subview:(NSString *)name; + +- (CGRect)viewFrame; +- (CGRect)viewBound; +- (CGSize)viewSize; + +@end diff --git a/BeeFramework/MVC/ViewController/Extension/UIViewController+BeeExtension.m b/BeeFramework/MVC/ViewController/Extension/UIViewController+BeeExtension.m new file mode 100644 index 0000000..2d03aa2 --- /dev/null +++ b/BeeFramework/MVC/ViewController/Extension/UIViewController+BeeExtension.m @@ -0,0 +1,137 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// UIView+BeeBackground.m +// + +#import "Bee_Precompile.h" +#import "UIView+BeeExtension.h" +#import "UIViewController+BeeExtension.h" +#include +#include + +#pragma mark - + +@implementation UIViewController(BeeExtension) + +@dynamic titleString; +@dynamic titleView; + +- (NSString *)titleString +{ + return self.navigationItem.title ? self.navigationItem.title : self.title; +} + +- (void)setTitleString:(NSString *)text +{ + self.navigationItem.title = text; +} + +- (UIView *)titleView +{ + return self.navigationItem.titleView; +} + +- (void)setTitleView:(UIView *)view +{ + self.navigationItem.titleView = view; +} + +- (UIView *)viewIfLoaded +{ + if ( NO == self.isViewLoaded ) + return nil; + + return self.view; +} + +- (UIView *)viewWithTagString:(NSString *)value +{ + if ( NO == self.isViewLoaded ) + return nil; + + return [self.view viewWithTagString:value]; +} + +- (UIView *)viewAtPath:(NSString *)path +{ + if ( NO == self.isViewLoaded ) + return nil; + + return [self.view viewAtPath:path]; +} + +- (UIView *)subview:(NSString *)name +{ + if ( NO == self.isViewLoaded ) + return nil; + + return [self.view subview:name]; +} + +- (CGRect)viewFrame +{ + CGRect bounds = [UIScreen mainScreen].bounds; + +// UIInterfaceOrientation orient = [UIApplication sharedApplication].statusBarOrientation; +// CGRect applicationframe = [UIScreen mainScreen].applicationFrame; + + if ( UIInterfaceOrientationIsLandscape(self.interfaceOrientation) ) + { + bounds.origin = CGPointMake( bounds.origin.y, bounds.origin.x ); + bounds.size = CGSizeMake( bounds.size.height, bounds.size.width ); + } + + if ( NO == [UIApplication sharedApplication].statusBarHidden ) + { + bounds.origin.y += 20; + bounds.size.height -= 20; + } + + if ( NO == self.navigationController.navigationBarHidden ) + { + bounds.size.height -= self.navigationController.navigationBar.bounds.size.height; + } + + return bounds; +} + +- (CGRect)viewBound +{ + CGRect bound = self.viewFrame; + bound.origin = CGPointZero; + return bound; +} + +- (CGSize)viewSize +{ + return self.viewFrame.size; +} + +@end diff --git a/BeeFramework/MVC/ViewController/Extension/UIViewController+BeeUISignal.h b/BeeFramework/MVC/ViewController/Extension/UIViewController+BeeUISignal.h new file mode 100644 index 0000000..8119ec6 --- /dev/null +++ b/BeeFramework/MVC/ViewController/Extension/UIViewController+BeeUISignal.h @@ -0,0 +1,49 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// UIViewController+BeeUISignal.h +// + +#import "Bee_Precompile.h" +#import "NSObject+BeeProperty.h" + +#pragma mark - + +@interface UIViewController(BeeUISignal) + ++ (NSString *)SIGNAL; ++ (NSString *)SIGNAL_TYPE; + +- (void)handleUISignal:(BeeUISignal *)signal; + +- (BeeUISignal *)sendUISignal:(NSString *)name; +- (BeeUISignal *)sendUISignal:(NSString *)name withObject:(NSObject *)object; +- (BeeUISignal *)sendUISignal:(NSString *)name withObject:(NSObject *)object from:(id)source; + +@end diff --git a/BeeFramework/MVC/ViewController/Extension/UIViewController+BeeUISignal.m b/BeeFramework/MVC/ViewController/Extension/UIViewController+BeeUISignal.m new file mode 100644 index 0000000..c9c387f --- /dev/null +++ b/BeeFramework/MVC/ViewController/Extension/UIViewController+BeeUISignal.m @@ -0,0 +1,88 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// UIViewController+BeeUISignal.m +// + +#import "Bee_Precompile.h" +#import "Bee_UISignal.h" +#import "Bee_Log.h" +#import "UIView+BeeExtension.h" +#import "UIViewController+BeeUISignal.h" + +#import + +#pragma mark - + +@implementation UIViewController(BeeUISignal) + ++ (NSString *)SIGNAL +{ + return [self SIGNAL_TYPE]; +} + ++ (NSString *)SIGNAL_TYPE +{ + return [NSString stringWithFormat:@"signal.%@.", [self description]]; +} + +- (void)handleUISignal:(BeeUISignal *)signal +{ + signal.reach = YES; + +#if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ + CC( @"[%@] > %@", signal.name, signal.callPath ); +#endif // #if defined(__BEE_DEVELOPMENT__) && __BEE_DEVELOPMENT__ +} + +- (BeeUISignal *)sendUISignal:(NSString *)name +{ + return [self sendUISignal:name withObject:nil from:self]; +} + +- (BeeUISignal *)sendUISignal:(NSString *)name withObject:(NSObject *)object +{ + return [self sendUISignal:name withObject:object from:self]; +} + +- (BeeUISignal *)sendUISignal:(NSString *)name withObject:(NSObject *)object from:(id)source +{ + BeeUISignal * signal = [[[BeeUISignal alloc] init] autorelease]; + if ( signal ) + { + signal.source = source ? source : self; + signal.target = self; + signal.name = name; + signal.object = object; + [signal send]; + } + return signal; +} + +@end diff --git a/BeeFramework/MVC/ViewController/Extension/UIViewController+UINavigationBar.h b/BeeFramework/MVC/ViewController/Extension/UIViewController+UINavigationBar.h new file mode 100644 index 0000000..3ef7515 --- /dev/null +++ b/BeeFramework/MVC/ViewController/Extension/UIViewController+UINavigationBar.h @@ -0,0 +1,65 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_UIBoard.h +// + +#import "Bee_Precompile.h" +#import "Bee_UISignal.h" +#import "Bee_UILabel.h" +#import "Bee_UIStack.h" + +#import "NSObject+BeeProperty.h" + +#pragma mark - + +@interface UINavigationBar(UINavigationBar) + +AS_INT( BARBUTTON_LEFT ) // 左按钮 +AS_INT( BARBUTTON_RIGHT ) // 右按钮 + +AS_SIGNAL( BACK_BUTTON_TOUCHED ) // NavigationBar左按钮被点击 +AS_SIGNAL( DONE_BUTTON_TOUCHED ) // NavigationBar右按钮被点击 + +@end + +#pragma mark - + +@interface UIViewController(UINavigationBar) + +- (void)showNavigationBarAnimated:(BOOL)animated; +- (void)hideNavigationBarAnimated:(BOOL)animated; + +- (void)showBarButton:(NSInteger)position title:(NSString *)name; +- (void)showBarButton:(NSInteger)position image:(UIImage *)image; +- (void)showBarButton:(NSInteger)position system:(UIBarButtonSystemItem)index; +- (void)showBarButton:(NSInteger)position custom:(UIView *)view; +- (void)hideBarButton:(NSInteger)position; + +@end diff --git a/BeeFramework/MVC/ViewController/Extension/UIViewController+UINavigationBar.m b/BeeFramework/MVC/ViewController/Extension/UIViewController+UINavigationBar.m new file mode 100644 index 0000000..555bf98 --- /dev/null +++ b/BeeFramework/MVC/ViewController/Extension/UIViewController+UINavigationBar.m @@ -0,0 +1,158 @@ +// +// ______ ______ ______ +// /\ __ \ /\ ___\ /\ ___\ +// \ \ __< \ \ __\_ \ \ __\_ +// \ \_____\ \ \_____\ \ \_____\ +// \/_____/ \/_____/ \/_____/ +// +// Copyright (c) 2012 BEE creators +// http://www.whatsbug.com +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +// +// +// Bee_UIBoard.m +// + +#import "Bee_Precompile.h" +#import "Bee_Log.h" +#import "Bee_UISignal.h" +#import "UIViewController+UINavigationBar.h" + +#pragma mark - + +@implementation UINavigationBar(UINavigationBar) + +DEF_SIGNAL( BACK_BUTTON_TOUCHED ) +DEF_SIGNAL( DONE_BUTTON_TOUCHED ) + +DEF_INT( BARBUTTON_LEFT, 0 ) +DEF_INT( BARBUTTON_RIGHT, 1 ) + +@end + +#pragma mark - + +@interface UIViewController(UINavigationBarPrivate) +- (void)didLeftBarButtonTouched; +- (void)didRightBarButtonTouched; +@end + +#pragma mark - + +@implementation UIViewController(UINavigationBar) + +- (void)showNavigationBarAnimated:(BOOL)animated +{ + [self.navigationController setNavigationBarHidden:NO animated:animated]; +} + +- (void)hideNavigationBarAnimated:(BOOL)animated +{ + [self.navigationController setNavigationBarHidden:YES animated:animated]; +} + +- (void)didLeftBarButtonTouched +{ + [self sendUISignal:UINavigationBar.BACK_BUTTON_TOUCHED]; +} + +- (void)didRightBarButtonTouched +{ + [self sendUISignal:UINavigationBar.DONE_BUTTON_TOUCHED]; +} + +- (void)showBarButton:(NSInteger)position title:(NSString *)name +{ + if ( UINavigationBar.BARBUTTON_LEFT == position ) + { + self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:name + style:UIBarButtonItemStylePlain + target:self + action:@selector(didLeftBarButtonTouched)] autorelease]; + } + else + { + self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:name + style:UIBarButtonItemStylePlain + target:self + action:@selector(didRightBarButtonTouched)] autorelease]; + } +} + +- (void)showBarButton:(NSInteger)position image:(UIImage *)image +{ + UIButton * button = [[[UIButton alloc] initWithFrame:CGRectMake(0, 0, image.size.width, image.size.height)] autorelease]; + button.contentMode = UIViewContentModeScaleAspectFit; + button.backgroundColor = [UIColor clearColor]; + [button setImage:image forState:UIControlStateNormal]; + + if ( UINavigationBar.BARBUTTON_LEFT == position ) + { + [button addTarget:self action:@selector(didLeftBarButtonTouched) forControlEvents:UIControlEventTouchUpInside]; + self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:button] autorelease]; + } + else + { + [button addTarget:self action:@selector(didRightBarButtonTouched) forControlEvents:UIControlEventTouchUpInside]; + self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:button] autorelease]; + } +} + +- (void)showBarButton:(NSInteger)position system:(UIBarButtonSystemItem)index +{ + if ( UINavigationBar.BARBUTTON_LEFT == position ) + { + self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:index + target:self + action:@selector(didLeftBarButtonTouched)] autorelease]; + } + else + { + self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:index + target:self + action:@selector(didRightBarButtonTouched)] autorelease]; + } +} + +- (void)showBarButton:(NSInteger)position custom:(UIView *)view +{ + if ( UINavigationBar.BARBUTTON_LEFT == position ) + { + self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:view] autorelease]; + } + else + { + self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:view] autorelease]; + } +} + +- (void)hideBarButton:(NSInteger)position +{ + if ( UINavigationBar.BARBUTTON_LEFT == position ) + { + self.navigationItem.leftBarButtonItem = nil; + } + else + { + self.navigationItem.rightBarButtonItem = nil; + } +} + +@end diff --git a/BeeFramework/Storage/Bee_ActiveRecord.m b/BeeFramework/Storage/Bee_ActiveRecord.m deleted file mode 100644 index e9a4d60..0000000 --- a/BeeFramework/Storage/Bee_ActiveRecord.m +++ /dev/null @@ -1,776 +0,0 @@ -// -// ______ ______ ______ -// /\ __ \ /\ ___\ /\ ___\ -// \ \ __< \ \ __\_ \ \ __\_ -// \ \_____\ \ \_____\ \ \_____\ -// \/_____/ \/_____/ \/_____/ -// -// Copyright (c) 2012 BEE creators -// http://www.whatsbug.com -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -// IN THE SOFTWARE. -// -// -// Bee_ActiveRecord.h -// - -#import "Bee_Precompile.h" -#import "Bee_Log.h" -#import "Bee_ActiveRecord.h" -#import "Bee_Database.h" -#import "NSNumber+BeeExtension.h" - -#include - -#pragma mark - - -@implementation BeeBaseActiveRecord - -- (id)init -{ - self = [super init]; - if ( self ) - { - [self load]; - } - return self; -} - -- (id)initWithDict:(NSDictionary *)dict -{ - self = [super init]; - if ( self ) - { - [self load]; - } - return self; -} - -- (void)setValue:(id)value forUndefinedKey:(NSString *)key -{ - CC( @"[ERROR] undefined key '%@'", key ); -} - -- (void)bindDict:(NSDictionary *)dict -{ - if ( nil == dict ) - return; - - NSArray * allKeys = [dict allKeys]; - for ( NSString * key in allKeys ) - { - NSObject * value = [dict objectForKey:key]; - if ( value && NO == [value isKindOfClass:[NSNull class]] ) - { - [self setValue:value forKey:key]; - } - } -} - -- (void)dealloc -{ - [self unload]; - [super dealloc]; -} - -- (void)load -{ - -} - -- (void)unload -{ - -} - -- (BOOL)insert -{ - return NO; -} - -- (BOOL)update -{ - return NO; -} - -- (BOOL)delete -{ - return NO; -} - -@end - -#pragma mark - - -#define ATTR_TYPE_UNKNOWN (0) -#define ATTR_TYPE_NUMBER (2) -#define ATTR_TYPE_TEXT (3) - -#pragma mark - - -@interface NonValue : NSObject -+ (NonValue *)value; -@end - -@implementation NonValue -+ (NonValue *)value -{ - return [[[NonValue alloc] init] autorelease]; -} -@end - -#pragma mark - - -@interface BeeActiveRecord(Private) - -- (void)initSelf; -- (void)bindDict:(NSDictionary *)dict; - -+ (BOOL)prepareTableOnce; -+ (BOOL)prepareLayoutOnce; -+ (void)prepare; - -+ (NSString *)primaryKey; -+ (NSUInteger)attributeType:(const char *)attr; - -+ (NSString *)tableName; -+ (NSArray *)properties; - -@end - -#pragma mark - - -@implementation BeeActiveRecord - -@synthesize ID = _ID; - -@dynamic INSERT; -@dynamic UPDATE; -@dynamic DELETE; - -static NSMutableDictionary * __tableCache = nil; -static NSMutableDictionary * __layoutCache = nil; - -static NSMutableDictionary * __primaryKeys = nil; -static NSMutableDictionary * __userProperties = nil; - -+ (BeeDatabase *)DB -{ - [self prepare]; - - return [super DB].CLASS( self ); -} - -+ (void)mapRelation -{ -} - -+ (void)mapPropertyAsKey:(NSString *)name -{ - if ( nil == __primaryKeys ) - { - __primaryKeys = [[NSMutableDictionary alloc] init]; - } - - [__primaryKeys setObject:name forKey:[self description]]; - - [self mapProperty:name]; -} - -+ (void)mapProperty:(NSString *)name -{ - [self mapProperty:name defaultValue:nil]; -} - -+ (void)mapProperty:(NSString *)name defaultValue:(id)value -{ - if ( nil == __userProperties ) - { - __userProperties = [[NSMutableDictionary alloc] init]; - } - - NSMutableDictionary * relation = (NSMutableDictionary *)[__userProperties objectForKey:[self description]]; - if ( nil == relation ) - { - relation = [NSMutableDictionary dictionary]; - [__userProperties setObject:relation forKey:[self description]]; - } - - [relation setObject:(value ? value : [NonValue value]) forKey:name]; -} - -+ (NSString *)primaryKey -{ - if ( __primaryKeys ) - { - return (NSString *)[__primaryKeys objectForKey:[self description]]; - } - - return @"id"; -} - -+ (NSString *)tableNameFor:(Class)clazz -{ - return [NSString stringWithFormat:@"table_%@",[clazz description].lowercaseString]; -} - -+ (NSString *)tableName -{ - return [NSString stringWithFormat:@"table_%@",[self description].lowercaseString]; -} - -+ (NSUInteger)attributeType:(const char *)attr -{ - NSAssert( attr[0] == 'T', @"" ); - - const char * type = &attr[1]; - if ( type[0] == '@' ) - { - if ( type[1] != '"' ) - return ATTR_TYPE_UNKNOWN; - - char typeClazz[64] = { 0 }; - - const char * clazz = &type[2]; - const char * clazzEnd = strchr( clazz, '"' ); - - if ( clazzEnd && clazz != clazzEnd ) - { - unsigned int size = (unsigned int)(clazzEnd - clazz); - strncpy( &typeClazz[0], clazz, size ); - } - - if ( 0 == strcmp((const char *)typeClazz, "NSNumber") ) - { - return ATTR_TYPE_NUMBER; - } - else if ( 0 == strcmp((const char *)typeClazz, "NSString") ) - { - return ATTR_TYPE_TEXT; - } - } - else if ( type[0] == '[' ) - { - return ATTR_TYPE_UNKNOWN; - } - else if ( type[0] == '{' ) - { - return ATTR_TYPE_UNKNOWN; - } - else - { - if ( type[0] == 'c' || type[0] == 'C' ) - { - return ATTR_TYPE_UNKNOWN; - } - else if ( type[0] == 'i' || type[0] == 's' || type[0] == 'l' || type[0] == 'q' ) - { - return ATTR_TYPE_UNKNOWN; - } - else if ( type[0] == 'I' || type[0] == 'S' || type[0] == 'L' || type[0] == 'Q' ) - { - return ATTR_TYPE_UNKNOWN; - } - else if ( type[0] == 'f' ) - { - return ATTR_TYPE_UNKNOWN; - } - else if ( type[0] == 'd' ) - { - return ATTR_TYPE_UNKNOWN; - } - else if ( type[0] == 'B' ) - { - return ATTR_TYPE_UNKNOWN; - } - else if ( type[0] == 'v' ) - { - return ATTR_TYPE_UNKNOWN; - } - else if ( type[0] == '*' ) - { - return ATTR_TYPE_UNKNOWN; - } - else if ( type[0] == ':' ) - { - return ATTR_TYPE_UNKNOWN; - } - else if ( 0 == strcmp(type, "bnum") ) - { - return ATTR_TYPE_UNKNOWN; - } - else if ( type[0] == '^' ) - { - return ATTR_TYPE_UNKNOWN; - } - else if ( type[0] == '?' ) - { - return ATTR_TYPE_UNKNOWN; - } - else - { - return ATTR_TYPE_UNKNOWN; - } - } - - return ATTR_TYPE_UNKNOWN; -} - -+ (NSArray *)properties -{ - if ( nil == __layoutCache ) - return nil; - - NSDictionary * dict = (NSDictionary *)[__layoutCache objectForKey:[self description]]; - if ( nil == dict ) - return nil; - - return dict.allKeys; -} - -+ (BOOL)prepareTableOnce -{ - if ( nil == __tableCache ) - { - __tableCache = [[NSMutableDictionary alloc] init]; - } - - NSNumber * status = [__tableCache objectForKey:self.tableName]; - if ( nil == status || 0 == status.intValue ) - { - NSString * className = [self description]; - - NSDictionary * layout = (NSDictionary *)[__layoutCache objectForKey:className]; - if ( nil == layout ) - return NO; - - NSArray * names = layout.allKeys; - if ( 0 == names.count ) - return NO; - - NSNumber * type = (NSNumber *)[layout objectForKey:self.primaryKey]; - if ( nil == type || ATTR_TYPE_NUMBER != type.intValue ) - return NO; - - NSDictionary * relation = (NSDictionary *)[__userProperties objectForKey:className]; - if ( nil == relation ) - return NO; - - [super DB] - .TABLE( self.tableName ) - .FIELD( self.primaryKey, @"INTEGER", 12 ).PRIMARY_KEY().AUTO_INREMENT(); - - for ( NSString * name in names ) - { - type = (NSNumber *)[layout objectForKey:name]; - if ( type ) - { - if ( ATTR_TYPE_NUMBER == type.intValue ) - { - [super DB].FIELD( name, @"INTEGER" ); - } - else if ( ATTR_TYPE_TEXT == type.intValue ) - { - [super DB].FIELD( name, @"TEXT" ); - } - } - - if ( relation ) - { - NSObject * defaultValue = [relation objectForKey:name]; - if ( defaultValue && NO == [defaultValue isKindOfClass:[NonValue class]] ) - { - [super DB].DEFAULT( defaultValue ); - } - } - } - - [super DB].CREATE_IF_NOT_EXISTS(); - - [super DB] - .TABLE( self.tableName ) - .INDEX_ON( self.primaryKey, nil ); - - [__tableCache setObject:__INT(1) forKey:self.tableName]; - } - - return YES; -} - -+ (BOOL)prepareLayoutOnce -{ - if ( nil == __layoutCache ) - { - __layoutCache = [[NSMutableDictionary alloc] init]; - } - - NSString * className = [self description]; - NSMutableDictionary * layout = (NSMutableDictionary *)[__layoutCache objectForKey:className]; - if ( nil == layout ) - { - [self mapRelation]; - - NSUInteger propertyCount = 0; - objc_property_t * properties = class_copyPropertyList( self, &propertyCount ); - - if ( NULL == properties || 0 == propertyCount ) - return NO; - - NSMutableDictionary * relation = [__userProperties objectForKey:className]; - if ( nil == relation ) - return NO; - - layout = [NSMutableDictionary dictionary]; - - for ( NSUInteger i = 0; i < propertyCount; i++ ) - { - const char * name = property_getName(properties[i]); - NSString * propertyName = [NSString stringWithCString:name encoding:NSUTF8StringEncoding]; - - if ( nil == [relation objectForKey:propertyName] ) - continue; - - const char * attr = property_getAttributes(properties[i]); - NSUInteger propertyType = [self attributeType:attr]; - - [layout setObject:__INT(propertyType) forKey:propertyName]; - } - - [__layoutCache setObject:layout forKey:className]; - } - - return YES; -} - -+ (void)prepare -{ - if ( [[self description] isEqualToString:[[BeeBaseActiveRecord class] description]] ) - return; - - if ( [[self description] isEqualToString:[[BeeActiveRecord class] description]] ) - return; - - [self prepareLayoutOnce]; - [self prepareTableOnce]; -} - -- (void)initSelf -{ - [[self class] prepare]; - - NSString * className = [[self class] description]; - NSDictionary * relation = (NSDictionary *)[__userProperties objectForKey:className]; - - NSString * primaryKey = [self class].primaryKey; - NSArray * properties = [self class].properties; - for ( NSString * name in properties ) - { - if ( [name isEqualToString:primaryKey] ) - continue; - - if ( relation ) - { - NSObject * defaultValue = [relation objectForKey:name]; - if ( defaultValue && NO == [defaultValue isKindOfClass:[NonValue class]] ) - { - [self setValue:defaultValue forKey:name]; - } - } - } -} - -- (id)init -{ - self = [super init]; - if ( self ) - { - [self initSelf]; - } - return self; -} - -- (id)initWithDict:(NSDictionary *)dict -{ - self = [super init]; - if ( self ) - { - [self initSelf]; - [self bindDict:dict]; - } - return self; -} - -- (void)bindDict:(NSDictionary *)dict -{ - if ( nil == dict ) - return; - - [super bindDict:dict]; - - NSNumber * value = [dict objectForKey:[self class].primaryKey]; - if ( value || [value isKindOfClass:[NSNumber class]] ) - { - self.ID = value; - } -} - -- (void)dealloc -{ - [super dealloc]; -} - -- (BOOL)insert -{ - NSString * key = [self class].primaryKey; - if ( nil == key ) - return NO; - - NSArray * properties = [self class].properties; - if ( nil == properties || 0 == properties.count ) - return NO; - - [super DB].FROM( [self class].tableName ); - - for ( NSString * property in properties ) - { - if ( [property isEqualToString:key] ) - continue; - - NSObject * propertyValue = [self valueForKey:property]; - if ( propertyValue ) - { - [super DB].SET( property, propertyValue ); - } - } - - [super DB].INSERT(); - - if ( [super DB].succeed ) - { - self.ID = __INT( [super DB].insertID ); - - [self setValue:self.ID forKey:[self class].primaryKey]; - return YES; - } - - return NO; -} - -- (BOOL)update -{ - if ( nil == self.ID || self.ID.intValue < 0 ) - return NO; - - NSString * key = [self class].primaryKey; - if ( nil == key ) - return NO; - - NSObject * value = [self valueForKey:key]; - if ( nil == value ) - return NO; - - NSArray * properties = [self class].properties; - if ( nil == properties || 0 == properties.count ) - return NO; - - [super DB] - .FROM( [self class].tableName ) - .WHERE( key, value ); - - for ( NSString * property in properties ) - { - if ( [property isEqualToString:key] ) - continue; - - NSObject * propertyValue = [self valueForKey:property]; - if ( propertyValue ) - { - [super DB].SET( property, propertyValue ); - } - } - - [super DB].UPDATE(); - - return [super DB].succeed; -} - -- (BOOL)delete -{ - if ( nil == self.ID || self.ID.intValue < 0 ) - return NO; - - NSString * key = [self class].primaryKey; - if ( nil == key ) - return NO; - - NSObject * value = [self valueForKey:key]; - if ( nil == value ) - return NO; - - NSArray * properties = [self class].properties; - if ( nil == properties || 0 == properties.count ) - return NO; - - [super DB] - .FROM( [self class].tableName ) - .WHERE( key, value ) - .DELETE(); - - if ( [super DB].succeed ) - { - for ( NSString * property in properties ) - { - if ( [property isEqualToString:key] ) - continue; - - [self setValue:nil forKey:property]; - } - - self.ID = __INT( -1 ); - - [self setValue:self.ID forKey:[self class].primaryKey]; - return YES; - } - - return NO; -} - -- (BeeActiveRecordBoolBlock)INSERT -{ - BeeActiveRecordBoolBlock block = ^ BOOL ( void ) - { - return [self insert]; - }; - - return [[block copy] autorelease]; -} - -- (BeeActiveRecordBoolBlock)UPDATE -{ - BeeActiveRecordBoolBlock block = ^ BOOL ( void ) - { - return [self update]; - }; - - return [[block copy] autorelease]; -} - -- (BeeActiveRecordBoolBlock)DELETE -{ - BeeActiveRecordBoolBlock block = ^ BOOL ( void ) - { - return [self delete]; - }; - - return [[block copy] autorelease]; -} - -@end - -#pragma mark - - -@implementation BeeDatabase(BeeActiveRecord) - -@dynamic CLASS; -@dynamic GET_RECORDS; - -- (BeeDatabaseBlockN)CLASS -{ - BeeDatabaseBlockN block = ^ BeeDatabase * ( id first, ... ) - { - [self classType:(Class)first]; - return self; - }; - - return [[block copy] autorelease]; -} - -- (BeeDatabaseArrayBlock)GET_RECORDS -{ - BeeDatabaseArrayBlock block = ^ NSArray * ( void ) - { - return [self getRecords]; - }; - - return [[block copy] autorelease]; -} - -- (void)classType:(Class)clazz -{ - if ( nil == clazz || NO == [clazz isSubclassOfClass:[BeeActiveRecord class]] ) - return; - - [_userInfo addObject:[clazz description]]; - - [super DB].FROM( [BeeActiveRecord tableNameFor:clazz] ); -} - -- (NSArray *)getRecords -{ - return [self getRecords:nil limit:0 offset:0]; -} - -- (NSArray *)getRecords:(NSString *)table -{ - return [self getRecords:table limit:0 offset:0]; -} - -- (NSArray *)getRecords:(NSString *)table limit:(NSUInteger)limit -{ - return [self getRecords:table limit:limit offset:0]; -} - -- (NSArray *)getRecords:(NSString *)table limit:(NSUInteger)limit offset:(NSUInteger)offset -{ - [self __internalResetResult]; - - if ( 0 == _userInfo.count ) - return [NSArray array]; - - NSString * className = _userInfo.lastObject; - if ( nil == className || 0 == className.length ) - return [NSArray array]; - - Class classType = NSClassFromString( className ); - if ( nil == classType || NO == [classType isSubclassOfClass:[BeeActiveRecord class]] ) - return [NSArray array]; - - NSArray * array = [[super DB] get:table limit:limit offset:offset]; - if ( nil == array || 0 == array.count ) - { - return [NSArray array]; - } - - NSMutableArray * activeRecords = [[NSMutableArray alloc] init]; - - for ( NSDictionary * dict in array ) - { - BeeActiveRecord * record = [[[classType alloc] initWithDict:dict] autorelease]; - [activeRecords addObject:record]; - } - - [_resultArray removeAllObjects]; - [_resultArray addObjectsFromArray:activeRecords]; - - [activeRecords release]; - - return _resultArray; -} - -@end diff --git a/BeeFramework/Storage/Bee_ActiveRecordTest.m b/BeeFramework/Storage/Bee_ActiveRecordTest.m deleted file mode 100644 index 045bfc5..0000000 --- a/BeeFramework/Storage/Bee_ActiveRecordTest.m +++ /dev/null @@ -1,206 +0,0 @@ -// -// ______ ______ ______ -// /\ __ \ /\ ___\ /\ ___\ -// \ \ __< \ \ __\_ \ \ __\_ -// \ \_____\ \ \_____\ \ \_____\ -// \/_____/ \/_____/ \/_____/ -// -// Copyright (c) 2012 BEE creators -// http://www.whatsbug.com -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -// IN THE SOFTWARE. -// -// -// Bee_DatabaseTest.h -// - -#import "Bee_Log.h" -#import "Bee_Database.h" -#import "Bee_ActiveRecordTest.h" - -#import "NSNumber+BeeExtension.h" - -#pragma mark - - -@interface UserInfo : BeeActiveRecord -{ - NSNumber * _uid; - NSString * _name; - NSString * _gender; - NSString * _city; -} - -@property (nonatomic, retain) NSNumber * uid; -@property (nonatomic, retain) NSString * name; -@property (nonatomic, retain) NSString * gender; -@property (nonatomic, retain) NSString * city; - -@end - -#pragma mark - - -@implementation UserInfo - -@synthesize uid = _uid; -@synthesize name = _name; -@synthesize gender = _gender; -@synthesize city = _city; - -+ (void)mapRelation -{ - [self mapPropertyAsKey:@"uid"]; - [self mapProperty:@"name"]; - [self mapProperty:@"gender" defaultValue:@"-"]; - [self mapProperty:@"city" defaultValue:@"Beijing"]; -} - -- (void)load -{ - [super load]; -} - -- (void)unload -{ - self.uid = nil; - self.name = nil; - self.gender = nil; - - [super unload]; -} - -@end - -#pragma mark - - -@implementation BeeActiveRecordTest - -+ (void)testViaDB -{ - // Clear table - UserInfo.DB.EMPTY(); - - // Insert 2 records into table 'table_userinfo' - UserInfo.DB - .SET( @"name", @"gavin" ) - .SET( @"gender", @"male" ) - .INSERT(); - - UserInfo.DB - .SET( @"name", @"amanda" ) - .SET( @"gender", @"female" ) - .SET( @"city", @"Columbus" ) - .INSERT(); - - // Update records - UserInfo.DB - .WHERE( @"name", @"gavin" ) - .SET( @"city", @"Columbus" ) - .UPDATE(); - - // Query records - UserInfo.DB - .WHERE( @"city", @"Columbus" ) - .LIMIT( 10 ) - .GET(); // Results are NSDictionary - NSAssert( UserInfo.DB.succeed, @"" ); - NSAssert( UserInfo.DB.resultCount == 2, @"" ); - - for ( NSDictionary * dict in UserInfo.DB.resultArray ) - { - VAR_DUMP( dict ); - } - - // Delete records - UserInfo.DB - .WHERE( @"city", @"Columbus" ) - .DELETE(); - - // Count records - UserInfo.DB - .LIMIT( 10 ) - .COUNT(); - NSAssert( UserInfo.DB.succeed, @"" ); - NSAssert( UserInfo.DB.resultCount == 0, @"" ); -} - -+ (void)testViaObject -{ - // Clear table - UserInfo.DB.EMPTY(); - - // Insert 2 records into table 'table_userinfo' - UserInfo * record1 = [[UserInfo alloc] init]; - if ( record1 ) - { - record1.name = @"gavin"; - record1.gender = @"male"; - record1.INSERT(); - } - - UserInfo * record2 = [[UserInfo alloc] init]; - if ( record2 ) - { - record2.name = @"amanda"; - record2.gender = @"female"; - record2.city = @"Columbus"; - record2.INSERT(); - } - - // Update records - record1.city = @"Columbus"; - record1.UPDATE(); - - // Query records - UserInfo.DB - .WHERE( @"city", @"Columbus" ) - .LIMIT( 10 ) - .GET_RECORDS(); // Results are BeeActiveRecord - NSAssert( UserInfo.DB.succeed, @"" ); - NSAssert( UserInfo.DB.resultCount == 2, @"" ); - - for ( UserInfo * info in UserInfo.DB.resultArray ) - { - VAR_DUMP( info ); - } - - // Delete records - record1.DELETE(); - [record1 release]; - - record2.DELETE(); - [record2 release]; - - // Count records - UserInfo.DB - .LIMIT( 10 ) - .COUNT(); - NSAssert( UserInfo.DB.succeed, @"" ); - NSAssert( UserInfo.DB.resultCount == 0, @"" ); -} - -+ (void)run -{ - if ( [BeeDatabase openSharedDatabase:@"my.db"] ) - { - [self testViaDB]; - [self testViaObject]; - } -} - -@end diff --git a/BeeFramework/MVC/ViewController/Bee_UICameraBoard.h b/BeeTemplates/CustomBoard/Bee_UICameraBoard.h similarity index 96% rename from BeeFramework/MVC/ViewController/Bee_UICameraBoard.h rename to BeeTemplates/CustomBoard/Bee_UICameraBoard.h index 731c511..1440524 100644 --- a/BeeFramework/MVC/ViewController/Bee_UICameraBoard.h +++ b/BeeTemplates/CustomBoard/Bee_UICameraBoard.h @@ -35,10 +35,7 @@ #import #import -#import "Bee_Precompile.h" -#import "Bee_UISignal.h" -#import "Bee_UIGridCell.h" -#import "Bee_UIBoard.h" +#import "Bee.h" #pragma mark - diff --git a/BeeFramework/MVC/ViewController/Bee_UICameraBoard.m b/BeeTemplates/CustomBoard/Bee_UICameraBoard.m similarity index 98% rename from BeeFramework/MVC/ViewController/Bee_UICameraBoard.m rename to BeeTemplates/CustomBoard/Bee_UICameraBoard.m index a6eca79..7a0075e 100644 --- a/BeeFramework/MVC/ViewController/Bee_UICameraBoard.m +++ b/BeeTemplates/CustomBoard/Bee_UICameraBoard.m @@ -30,11 +30,7 @@ // Bee_UICameraBoard.m // -#import "Bee_Precompile.h" #import "Bee_UICameraBoard.h" -#import "Bee_UIOrientation.h" -#import "Bee_Runtime.h" -#import "Bee_Log.h" #pragma mark - @@ -601,8 +597,8 @@ - (CGPoint)focusPoint { #if !TARGET_IPHONE_SIMULATOR CGPoint point; - point.x = self.view.bounds.size.width * _captureDevice.focusPointOfInterest.x; - point.y = self.view.bounds.size.height * _captureDevice.focusPointOfInterest.y; + point.x = self.viewBound.size.width * _captureDevice.focusPointOfInterest.x; + point.y = self.viewBound.size.height * _captureDevice.focusPointOfInterest.y; return point; // return _captureDevice.focusPointOfInterest; #else // #if !TARGET_IPHONE_SIMULATOR diff --git a/BeeFramework/MVC/ViewController/Bee_UIFlowBoard.h b/BeeTemplates/CustomBoard/Bee_UIFlowBoard.h similarity index 94% rename from BeeFramework/MVC/ViewController/Bee_UIFlowBoard.h rename to BeeTemplates/CustomBoard/Bee_UIFlowBoard.h index 7428fcc..92e3942 100644 --- a/BeeFramework/MVC/ViewController/Bee_UIFlowBoard.h +++ b/BeeTemplates/CustomBoard/Bee_UIFlowBoard.h @@ -30,11 +30,7 @@ // Bee_UIFlowBoard.h // -#import "Bee_Precompile.h" -#import "Bee_UISignal.h" -#import "Bee_UIGridCell.h" -#import "Bee_UIPullLoader.h" -#import "Bee_UIBoard.h" +#import "Bee.h" #pragma mark - @@ -96,7 +92,6 @@ AS_SIGNAL( REACH_BOTTOM ) // 触底 - (void)cancelReloadData; - (void)showPullLoader:(BOOL)en animated:(BOOL)animated; -- (void)setBaseInsets:(UIEdgeInsets)insets; - (void)setPullLoading:(BOOL)en; - (void)scrollToTop:(BOOL)animated; diff --git a/BeeFramework/MVC/ViewController/Bee_UIFlowtBoard.m b/BeeTemplates/CustomBoard/Bee_UIFlowBoard.m similarity index 99% rename from BeeFramework/MVC/ViewController/Bee_UIFlowtBoard.m rename to BeeTemplates/CustomBoard/Bee_UIFlowBoard.m index 04589f3..650728a 100644 --- a/BeeFramework/MVC/ViewController/Bee_UIFlowtBoard.m +++ b/BeeTemplates/CustomBoard/Bee_UIFlowBoard.m @@ -30,12 +30,7 @@ // Bee_UIFlowBoard.m // -#import "Bee_Precompile.h" #import "Bee_UIFlowBoard.h" -#import "Bee_Performance.h" -#import "Bee_Runtime.h" -#import "Bee_Log.h" -#import "UIView+BeeQuery.h" #pragma mark - diff --git a/BeeFramework/MVC/ViewController/Bee_UITableBoard.h b/BeeTemplates/CustomBoard/Bee_UITableBoard.h similarity index 93% rename from BeeFramework/MVC/ViewController/Bee_UITableBoard.h rename to BeeTemplates/CustomBoard/Bee_UITableBoard.h index ed6e7fc..3d2554f 100644 --- a/BeeFramework/MVC/ViewController/Bee_UITableBoard.h +++ b/BeeTemplates/CustomBoard/Bee_UITableBoard.h @@ -30,23 +30,19 @@ // Bee_UITableBoard.h // -#import "Bee_Precompile.h" -#import "Bee_UIGridCell.h" -#import "Bee_UIPullLoader.h" -#import "Bee_UIBoard.h" -#import "Bee_UISignal.h" +#import "Bee.h" #pragma mark - @interface BeeUITableViewCell : UITableViewCell { - BeeUIGridCell * _innerCell; + BeeUIGridCell * _gridCell; } -@property (nonatomic, retain) BeeUIGridCell * innerCell; +@property (nonatomic, retain) BeeUIGridCell * gridCell; -- (void)bindData:(NSObject *)data; -- (void)bindCell:(BeeUIGridCell *)cell; +@property (nonatomic, retain) NSObject * cellData; +@property (nonatomic, retain) NSObject * cellLayout; @end diff --git a/BeeFramework/MVC/ViewController/Bee_UITableBoard.m b/BeeTemplates/CustomBoard/Bee_UITableBoard.m similarity index 94% rename from BeeFramework/MVC/ViewController/Bee_UITableBoard.m rename to BeeTemplates/CustomBoard/Bee_UITableBoard.m index bd60dc8..a1a668e 100644 --- a/BeeFramework/MVC/ViewController/Bee_UITableBoard.m +++ b/BeeTemplates/CustomBoard/Bee_UITableBoard.m @@ -30,14 +30,7 @@ // Bee_UITableBoard.m // -#import "Bee_Precompile.h" #import "Bee_UITableBoard.h" -#import "Bee_UIKeyboard.h" -#import "Bee_Runtime.h" -#import "Bee_Log.h" - -#import "CGRect+BeeExtension.h" -#import "UIView+BeeQuery.h" #import @@ -50,7 +43,10 @@ @implementation BeeUITableViewCell -@synthesize innerCell = _innerCell; +@dynamic gridCell; + +@dynamic cellData; +@dynamic cellLayout; - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { @@ -71,45 +67,69 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus self.contentView.layer.masksToBounds = YES; self.contentView.layer.opaque = YES; + self.contentView.autoresizesSubviews = YES; } return self; } -- (void)bindCell:(BeeUIGridCell *)cell +- (BeeUIGridCell *)gridCell { - if ( cell != self.innerCell ) + return _gridCell; +} + +- (void)setGridCell:(BeeUIGridCell *)gridCell +{ + if ( _gridCell != gridCell ) { - if ( cell.superview != self.contentView ) + [_gridCell release]; + + _gridCell = [gridCell retain]; + _gridCell.autoresizesSubviews = YES; + _gridCell.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; + + if ( gridCell.superview != self.contentView ) { - [cell.superview removeFromSuperview]; + [gridCell.superview removeFromSuperview]; } + + [self.contentView addSubview:_gridCell]; + } +} - self.innerCell = cell; - self.innerCell.category = self.reuseIdentifier; +- (NSObject *)cellData +{ + return _gridCell.cellData; +} - [self.contentView addSubview:self.innerCell]; - } +- (void)setCellData:(NSObject *)data +{ + _gridCell.cellData = data; +} + +- (NSObject *)cellLayout +{ + return _gridCell.cellLayout; } -- (void)bindData:(NSObject *)data +- (void)setCellLayout:(NSObject *)layout { - [_innerCell bindData:data]; + _gridCell.cellLayout = layout; } - (void)setFrame:(CGRect)rc { [super setFrame:CGRectZeroNan(rc)]; - [_innerCell setFrame:self.bounds]; -// [_innerCell layoutAllSubcells]; + [_gridCell setFrame:self.bounds]; +// [_gridCell layoutSubcells]; } - (void)setCenter:(CGPoint)pt { [super setCenter:pt]; - [_innerCell setFrame:self.bounds]; -// [_innerCell layoutAllSubcells]; + [_gridCell setFrame:self.bounds]; +// [_gridCell layoutSubcells]; } // if the cell is reusable (has a reuse identifier), @@ -118,33 +138,39 @@ - (void)setCenter:(CGPoint)pt - (void)prepareForReuse { [super prepareForReuse]; - - [_innerCell clearData]; + + _gridCell.cellData = nil; } - (void)willTransitionToState:(UITableViewCellStateMask)state { + [super willTransitionToState:state]; + self.showsReorderControl = NO; self.shouldIndentWhileEditing = NO; self.indentationLevel = 0; self.indentationWidth = 0.0f; - [_innerCell layoutAllSubcells]; + [_gridCell layoutSubcells]; } - (void)didTransitionToState:(UITableViewCellStateMask)state { + [super didTransitionToState:state]; + self.showsReorderControl = NO; self.shouldIndentWhileEditing = NO; self.indentationLevel = 0; self.indentationWidth = 0.0f; - [_innerCell layoutAllSubcells]; + [_gridCell layoutSubcells]; } - (void)dealloc { - SAFE_RELEASE_SUBVIEW(_innerCell); + [_gridCell removeFromSuperview]; + [_gridCell release]; + _gridCell = nil; [super dealloc]; } @@ -216,11 +242,7 @@ - (BeeUITableViewCell *)dequeueWithContentClass:(Class)clazz if ( nil == cell ) { cell = [[[BeeUITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:clazzName] autorelease]; - - BeeUIGridCell * innerCell = [(BeeUIGridCell *)[[BeeRuntime allocByClass:clazz] init] autorelease]; - [cell bindCell:innerCell]; - - // NSAssert( nil != cell.innerCell, @"out of memory" ); + cell.gridCell = [(BeeUIGridCell *)[[BeeRuntime allocByClass:clazz] init] autorelease]; } return cell; @@ -233,9 +255,7 @@ - (BeeUITableViewCell *)dequeueWithContentCell:(BeeUIGridCell *)innerCell if ( nil == cell ) { cell = [[[BeeUITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:clazzName] autorelease]; - [cell bindCell:innerCell]; - -// NSAssert( nil != cell.innerCell, @"out of memory" ); + cell.gridCell = innerCell; } return cell; @@ -246,9 +266,9 @@ - (BeeUIGridCell *)contentForRowAtIndexPath:(NSIndexPath *)indexPath BeeUITableViewCell * cell = (BeeUITableViewCell *)[self tableView:self.tableView cellForRowAtIndexPath:indexPath]; if ( cell ) { - return cell.innerCell; + return cell.gridCell; } - + return nil; } @@ -402,7 +422,7 @@ - (void)layoutSearchBar:(BOOL)animated if ( BeeUITableBoard.SEARCHBAR_STYLE_BOTTOM == _searchBarStyle ) { - CGRect bounds = self.view.bounds; + CGRect bounds = self.viewBound; CGRect searchFrame; searchFrame.origin.x = 0.0f; searchFrame.origin.y = bounds.size.height - SEARCH_BAR_HEIGHT; @@ -418,7 +438,7 @@ - (void)layoutSearchBar:(BOOL)animated } else { - CGRect bounds = self.view.bounds; + CGRect bounds = self.viewBound; CGRect searchFrame; searchFrame.origin.x = 0.0f; searchFrame.origin.y = 0.0f; // bounds.size.height - SEARCH_BAR_HEIGHT; @@ -450,7 +470,7 @@ - (void)layoutTableView:(BOOL)animated // [UIView setAnimationBeginsFromCurrentState:YES]; } - CGRect bounds = self.view.bounds; + CGRect bounds = self.viewBound; CGRect tableFrame; tableFrame.origin = CGPointZero; tableFrame.size.width = bounds.size.width; @@ -783,7 +803,7 @@ - (void)layoutViews:(BOOL)animated [UIView setAnimationDuration:0.3f]; } - CGRect bounds = self.view.bounds; + CGRect bounds = self.viewBound; if ( BeeUITableBoard.SEARCHBAR_STYLE_TOP == _searchBarStyle ) { diff --git a/BeeFramework/MVC/ViewController/Bee_UIWebBoard.h b/BeeTemplates/CustomBoard/Bee_UIWebBoard.h similarity index 93% rename from BeeFramework/MVC/ViewController/Bee_UIWebBoard.h rename to BeeTemplates/CustomBoard/Bee_UIWebBoard.h index 9d7d706..6750942 100644 --- a/BeeFramework/MVC/ViewController/Bee_UIWebBoard.h +++ b/BeeTemplates/CustomBoard/Bee_UIWebBoard.h @@ -30,10 +30,7 @@ // Bee_UIWebBoard.h // -#import "Bee_Precompile.h" -#import "Bee_UIBoard.h" -#import "Bee_UISignal.h" -#import "Bee_UIWebView.h" +#import "Bee.h" #pragma mark - diff --git a/BeeFramework/MVC/ViewController/Bee_UIWebBoard.m b/BeeTemplates/CustomBoard/Bee_UIWebBoard.m similarity index 97% rename from BeeFramework/MVC/ViewController/Bee_UIWebBoard.m rename to BeeTemplates/CustomBoard/Bee_UIWebBoard.m index 7d4cf7d..0810756 100644 --- a/BeeFramework/MVC/ViewController/Bee_UIWebBoard.m +++ b/BeeTemplates/CustomBoard/Bee_UIWebBoard.m @@ -30,9 +30,7 @@ // Bee_UIWebBoard.m // -#import "Bee_Precompile.h" #import "Bee_UIWebBoard.h" -#import "UIView+BeeQuery.h" #pragma mark - diff --git a/Contributors.txt b/Contributors.txt new file mode 100644 index 0000000..31f736d --- /dev/null +++ b/Contributors.txt @@ -0,0 +1,10 @@ + +@GavinKwoe +@Dengwei +@LiDonglin +@STCui +@Royall +@Lancy +@者年 + +感谢所有活跃在QQ群里童鞋们的支持! diff --git a/Example/Lessions/CatelogBoard.h b/Example/Lessions/CatelogBoard.h index 50392d1..9b906b8 100644 --- a/Example/Lessions/CatelogBoard.h +++ b/Example/Lessions/CatelogBoard.h @@ -3,6 +3,7 @@ // #import "Bee.h" +#import "Bee_UITableBoard.h" #pragma mark - diff --git a/Example/Lessions/CatelogBoard.m b/Example/Lessions/CatelogBoard.m index eae6e9c..3c5bfd7 100644 --- a/Example/Lessions/CatelogBoard.m +++ b/Example/Lessions/CatelogBoard.m @@ -10,12 +10,12 @@ @implementation CatelogCell -+ (CGSize)cellSize:(NSObject *)data bound:(CGSize)bound ++ (CGSize)sizeInBound:(CGSize)bound forData:(NSObject *)data { return CGSizeMake( bound.width, 60.0f ); } -- (void)cellLayout:(BeeUIGridCell *)cell bound:(CGSize)bound +- (void)layoutInBound:(CGSize)bound forCell:(BeeUIGridCell *)cell { _title.frame = CGRectMake( 10.0f, 5.0f, cell.bounds.size.width - 20.0f, 30.0f ); _intro.frame = CGRectMake( 10.0f, 32.0f, cell.bounds.size.width - 20.0f, 20.0f ); @@ -46,18 +46,25 @@ - (void)unload [super unload]; } -- (void)bindData:(NSObject *)data +- (void)dataWillChange { - [_title setText:[(NSArray *)data objectAtIndex:1]]; - [_intro setText:[(NSArray *)data objectAtIndex:2]]; - - [super bindData:data]; + [super dataWillChange]; } -- (void)clearData +- (void)dataDidChanged { - [_title setText:nil]; - [_intro setText:nil]; + [super dataDidChanged]; + + if ( self.cellData ) + { + [_title setText:[(NSArray *)self.cellData objectAtIndex:1]]; + [_intro setText:[(NSArray *)self.cellData objectAtIndex:2]]; + } + else + { + [_title setText:nil]; + [_intro setText:nil]; + } } @end @@ -113,7 +120,7 @@ - (void)handleUISignal:(BeeUISignal *)signal - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { CGSize bound = CGSizeMake( self.view.bounds.size.width, 0.0f ); - return [CatelogCell cellSize:nil bound:bound].height; + return [CatelogCell sizeInBound:bound forData:nil].height; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section @@ -128,16 +135,17 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N { if ( indexPath.row % 2 ) { - [cell.innerCell setBackgroundColor:[UIColor whiteColor]]; + [cell.gridCell setBackgroundColor:[UIColor whiteColor]]; } else { - [cell.innerCell setBackgroundColor:[UIColor colorWithWhite:0.95f alpha:1.0f]]; + [cell.gridCell setBackgroundColor:[UIColor colorWithWhite:0.95f alpha:1.0f]]; } [cell setSelectionStyle:UITableViewCellSelectionStyleGray]; [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator]; - [cell bindData:[_lessions objectAtIndex:indexPath.row]]; + + cell.cellData = [_lessions objectAtIndex:indexPath.row]; return cell; } return [super tableView:tableView cellForRowAtIndexPath:indexPath]; diff --git a/Example/Lessions/DribbbleBoard.h b/Example/Lessions/DribbbleBoard.h index 05b9b85..04e3092 100644 --- a/Example/Lessions/DribbbleBoard.h +++ b/Example/Lessions/DribbbleBoard.h @@ -4,6 +4,7 @@ #import "Bee.h" #import "DribbbleModel.h" +#import "Bee_UITableBoard.h" #pragma mark - diff --git a/Example/Lessions/DribbbleBoard.m b/Example/Lessions/DribbbleBoard.m index bd4bfaf..3f38a12 100644 --- a/Example/Lessions/DribbbleBoard.m +++ b/Example/Lessions/DribbbleBoard.m @@ -9,7 +9,7 @@ @implementation DribbbleCell -+ (CGSize)cellSize:(NSObject *)data bound:(CGSize)bound ++ (CGSize)sizeInBound:(CGSize)bound forData:(NSObject *)data { if ( data ) { @@ -23,32 +23,33 @@ + (CGSize)cellSize:(NSObject *)data bound:(CGSize)bound cellSize.height = photoSize.height; return cellSize; } - else - { - return [super cellSize:data bound:bound]; - } + + return bound; } -- (void)cellLayout:(BeeUIGridCell *)cell bound:(CGSize)bound +- (void)layoutInBound:(CGSize)bound forCell:(BeeUIGridCell *)cell { - CGSize photoSize; - photoSize.width = [[(NSDictionary *)cell.cellData numberAtPath:@"/width"] floatValue]; - photoSize.height = [[(NSDictionary *)cell.cellData numberAtPath:@"/height"] floatValue]; - photoSize = AspectFitSizeByWidth( photoSize, bound.width ); - - _photo.frame = CGRectMake( 0.0f, 0.0f, bound.width, photoSize.height ); - _mask.frame = CGRectMake( 0.0f, bound.height - 40.0f, bound.width, 40.0f ); + if ( cell.cellData ) + { + CGSize photoSize; + photoSize.width = [[(NSDictionary *)cell.cellData numberAtPath:@"/width"] floatValue]; + photoSize.height = [[(NSDictionary *)cell.cellData numberAtPath:@"/height"] floatValue]; + photoSize = AspectFitSizeByWidth( photoSize, bound.width ); + + _photo.frame = CGRectMake( 0.0f, 0.0f, bound.width, photoSize.height ); + _mask.frame = CGRectMake( 0.0f, bound.height - 40.0f, bound.width, 40.0f ); - _avatar.frame = CGRectMake( 5.0f, CGRectGetMinY(_mask.frame) + 5.0f, 30.0f, 30.0f ); - _title.frame = CGRectMake( 40.0f, CGRectGetMinY(_mask.frame) + 6.0f, bound.width - 40.0f - 80.0f, 14.0f ); - _time.frame = CGRectMake( bound.width - 80.0f, CGRectGetMinY(_title.frame), 80.0f, 14.0f ); - _name.frame = CGRectMake( 40.0f, CGRectGetMinY(_mask.frame) + 20.0f, bound.width - 40.0f, 14.0f ); + _avatar.frame = CGRectMake( 5.0f, CGRectGetMinY(_mask.frame) + 5.0f, 30.0f, 30.0f ); + _title.frame = CGRectMake( 40.0f, CGRectGetMinY(_mask.frame) + 6.0f, bound.width - 40.0f - 80.0f, 14.0f ); + _time.frame = CGRectMake( bound.width - 80.0f, CGRectGetMinY(_title.frame), 80.0f, 14.0f ); + _name.frame = CGRectMake( 40.0f, CGRectGetMinY(_mask.frame) + 20.0f, bound.width - 40.0f, 14.0f ); + } } - (void)load { [super load]; - + _photo = [[BeeUIImageView alloc] init]; _photo.contentMode = UIViewContentModeScaleAspectFit; _photo.indicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray; @@ -94,23 +95,25 @@ - (void)unload [super unload]; } -- (void)bindData:(NSObject *)data +- (void)dataDidChanged { - [_photo GET:[(NSDictionary *)data stringAtPath:@"/image_teaser_url"] useCache:YES]; - [_avatar GET:[(NSDictionary *)data stringAtPath:@"/player/avatar_url"] useCache:YES]; - [_title setText:[(NSDictionary *)data stringAtPath:@"/title"]]; - [_time setText:[[(NSDictionary *)data stringAtPath:@"/created_at"] substringToIndex:10]]; - [_name setText:[NSString stringWithFormat:@"by %@", [(NSDictionary *)data stringAtPath:@"/player/name"]]]; - - [super bindData:data]; -} - -- (void)clearData -{ - [_photo setImage:nil]; - [_avatar setImage:nil]; - [_title setText:nil]; - [_name setText:nil]; + [super dataDidChanged]; + + if ( self.cellData ) + { + [_photo GET:[(NSDictionary *)self.cellData stringAtPath:@"/image_teaser_url"] useCache:YES]; + [_avatar GET:[(NSDictionary *)self.cellData stringAtPath:@"/player/avatar_url"] useCache:YES]; + [_title setText:[(NSDictionary *)self.cellData stringAtPath:@"/title"]]; + [_time setText:[[(NSDictionary *)self.cellData stringAtPath:@"/created_at"] substringToIndex:10]]; + [_name setText:[NSString stringWithFormat:@"by %@", [(NSDictionary *)self.cellData stringAtPath:@"/player/name"]]]; + } + else + { + [_photo setImage:nil]; + [_avatar setImage:nil]; + [_title setText:nil]; + [_name setText:nil]; + } } @end @@ -133,13 +136,13 @@ - (void)load [super load]; _debutsModel = [DribbbleDebutsModel new]; - [_debutsModel bind:self]; + [_debutsModel addObserver:self]; _popularModel = [DribbblePopularModel new]; - [_debutsModel bind:self]; + [_popularModel addObserver:self]; _everyoneModel = [DribbbleEveryoneModel new]; - [_everyoneModel bind:self]; + [_everyoneModel addObserver:self]; } - (void)unload @@ -156,7 +159,7 @@ - (void)handleUISignal:(BeeUISignal *)signal [super handleUISignal:signal]; } -- (void)handleBeeUIBoard:(BeeUISignal *)signal +- (void)handleUISignal_BeeUIBoard:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -164,15 +167,17 @@ - (void)handleBeeUIBoard:(BeeUISignal *)signal { [self showNavigationBarAnimated:NO]; [self showPullLoader:YES animated:NO]; + + self.pullLoader.arrow.image = [UIImage imageNamed:@"bug.png"]; BeeUISegmentedControl * seg = [BeeUISegmentedControl spawn]; [seg addTitle:@"everyone" tag:TAG_EVERYONE]; [seg addTitle:@"debuts" tag:TAG_DEBUTS]; [seg addTitle:@"popular" tag:TAG_POPULAR]; - [self setTitleView:seg]; + self.titleView = seg; -// [self showBarButton:BeeUIBoard.BARBUTTON_LEFT title:@"Clear"]; - [self showBarButton:BeeUIBoard.BARBUTTON_RIGHT system:UIBarButtonSystemItemRefresh]; +// [self showBarButton:UINavigationBar.BARBUTTON_LEFT title:@"Clear"]; + [self showBarButton:UINavigationBar.BARBUTTON_RIGHT system:UIBarButtonSystemItemRefresh]; } else if ( [signal is:BeeUIBoard.DELETE_VIEWS] ) { @@ -196,17 +201,20 @@ - (void)handleBeeUIBoard:(BeeUISignal *)signal else if ( [signal is:BeeUIBoard.DID_DISAPPEAR] ) { } - else if ( [signal is:BeeUIBoard.BACK_BUTTON_TOUCHED] ) - { - +} + +- (void)handleUISignal_UINavigationBar:(BeeUISignal *)signal +{ + if ( [signal is:UINavigationBar.BACK_BUTTON_TOUCHED] ) + { } - else if ( [signal is:BeeUIBoard.DONE_BUTTON_TOUCHED] ) + else if ( [signal is:UINavigationBar.DONE_BUTTON_TOUCHED] ) { [self refresh:YES]; - } + } } -- (void)handleBeeUISegmentedControl:(BeeUISignal *)signal +- (void)handleUISignal_BeeUISegmentedControl:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -219,7 +227,7 @@ - (void)handleBeeUISegmentedControl:(BeeUISignal *)signal } } -- (void)handleBeeUITableBoard:(BeeUISignal *)signal +- (void)handleUISignal_BeeUITableBoard:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -234,7 +242,7 @@ - (void)handleMessage:(BeeMessage *)msg [super handleMessage:msg]; } -- (void)handleDribbbleController:(BeeMessage *)msg +- (void)handleMessage_DribbbleController:(BeeMessage *)msg { [super handleMessage:msg]; @@ -243,17 +251,18 @@ - (void)handleDribbbleController:(BeeMessage *)msg if ( msg.sending ) { BeeUIActivityIndicatorView * indicator = [BeeUIActivityIndicatorView spawn]; - [self showBarButton:BeeUIBoard.BARBUTTON_RIGHT custom:indicator]; + [self showBarButton:UINavigationBar.BARBUTTON_RIGHT custom:indicator]; [indicator startAnimating]; - [self showPullLoader:YES animated:YES]; + [self setPullLoading:YES]; } else { - [self showBarButton:BeeUIBoard.BARBUTTON_RIGHT system:UIBarButtonSystemItemRefresh]; - [self showPullLoader:NO animated:YES]; + [self showBarButton:UINavigationBar.BARBUTTON_RIGHT system:UIBarButtonSystemItemRefresh]; + + [self setPullLoading:NO]; } - + if ( msg.succeed || msg.failed ) { [self.tableView flashScrollIndicators]; @@ -318,7 +327,7 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa { NSData * data = [[self shots] safeObjectAtIndex:indexPath.row]; CGSize bound = CGSizeMake( self.view.bounds.size.width, 0.0f ); - return [DribbbleCell cellSize:data bound:bound].height; + return [DribbbleCell sizeInBound:bound forData:data].height; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section @@ -330,8 +339,8 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N { BeeUITableViewCell * cell = (BeeUITableViewCell *)[self dequeueWithContentClass:[DribbbleCell class]]; if ( cell ) - { - [cell bindData:[[self shots] safeObjectAtIndex:indexPath.row]]; + { + cell.cellData = [[self shots] safeObjectAtIndex:indexPath.row]; return cell; } @@ -341,7 +350,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [super tableView:tableView didSelectRowAtIndexPath:indexPath]; - + DribbblePhotoBoard * board = [[[DribbblePhotoBoard alloc] init] autorelease]; board.feed = [[self shots] safeObjectAtIndex:indexPath.row]; [self.stack pushBoard:board animated:YES]; diff --git a/Example/Lessions/DribbbleController.mm b/Example/Lessions/DribbbleController.mm index f8e7902..6617ed8 100644 --- a/Example/Lessions/DribbbleController.mm +++ b/Example/Lessions/DribbbleController.mm @@ -41,7 +41,7 @@ - (void)GET_SHOTS:(BeeMessage *)msg NSString * baseURL = [@"http://api.dribbble.com/shots/" stringByAppendingString:cate]; NSString * callURL = [baseURL urlByAppendingArray:[NSArray arrayWithObjects:@"page", page, @"per_page", size, nil]]; - [msg GET:callURL]; + msg.HTTP_GET( callURL ); } else if ( msg.progressed ) { @@ -66,9 +66,9 @@ - (void)GET_SHOTS:(BeeMessage *)msg if ( nil == shots ) { [msg setLastError]; - return; + return; } - + [msg output:@"total", total, @"shots", shots, nil]; } else if ( msg.failed ) diff --git a/Example/Lessions/DribbbleModel.m b/Example/Lessions/DribbbleModel.m index 129ad61..48edff2 100644 --- a/Example/Lessions/DribbbleModel.m +++ b/Example/Lessions/DribbbleModel.m @@ -138,7 +138,7 @@ - (void)handleMessage:(BeeMessage *)msg - (void)handleDribbbleController:(BeeMessage *)msg { [super handleMessage:msg]; - + if ( [msg is:DribbbleController.GET_SHOTS] ) { if ( msg.succeed ) diff --git a/Example/Lessions/DribbblePhotoBoard.m b/Example/Lessions/DribbblePhotoBoard.m index bbd144c..c673326 100644 --- a/Example/Lessions/DribbblePhotoBoard.m +++ b/Example/Lessions/DribbblePhotoBoard.m @@ -27,7 +27,7 @@ - (void)handleUISignal:(BeeUISignal *)signal [super handleUISignal:signal]; } -- (void)handleBeeUIBoard:(BeeUISignal *)signal +- (void)handleUISignal_BeeUIBoard:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -68,13 +68,6 @@ - (void)handleBeeUIBoard:(BeeUISignal *)signal else if ( [signal is:BeeUIBoard.DID_DISAPPEAR] ) { } - else if ( [signal is:BeeUIBoard.BACK_BUTTON_TOUCHED] ) - { - - } - else if ( [signal is:BeeUIBoard.DONE_BUTTON_TOUCHED] ) - { - } } @end diff --git a/Example/Lessions/Lession10Board.m b/Example/Lessions/Lession10Board.m index e58f446..88a7955 100644 --- a/Example/Lessions/Lession10Board.m +++ b/Example/Lessions/Lession10Board.m @@ -30,7 +30,7 @@ - (void)handleUISignal:(BeeUISignal *)signal [super handleUISignal:signal]; } -- (void)handleBeeUIBoard:(BeeUISignal *)signal +- (void)handleUISignal_BeeUIBoard:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -93,15 +93,9 @@ - (void)handleBeeUIBoard:(BeeUISignal *)signal else if ( [signal is:BeeUIBoard.DID_DISAPPEAR] ) { } - else if ( [signal is:BeeUIBoard.BACK_BUTTON_TOUCHED] ) - { - } - else if ( [signal is:BeeUIBoard.DONE_BUTTON_TOUCHED] ) - { - } } -- (void)handleLession10Board:(BeeUISignal *)signal +- (void)handleUISignal_Lession10Board:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -124,7 +118,7 @@ - (void)handleLession10Board:(BeeUISignal *)signal } } -- (void)handleBeeUITextView:(BeeUISignal *)signal +- (void)handleUISignal_BeeUITextView:(BeeUISignal *)signal { [super handleUISignal:signal]; diff --git a/Example/Lessions/Lession11Board.h b/Example/Lessions/Lession11Board.h index 26364f6..a57646a 100644 --- a/Example/Lessions/Lession11Board.h +++ b/Example/Lessions/Lession11Board.h @@ -4,6 +4,7 @@ #import "Lession10Model.h" #import "Bee.h" +#import "Bee_UITableBoard.h" #pragma mark - diff --git a/Example/Lessions/Lession11Board.m b/Example/Lessions/Lession11Board.m index 1e5bff1..8b6d85d 100644 --- a/Example/Lessions/Lession11Board.m +++ b/Example/Lessions/Lession11Board.m @@ -9,12 +9,12 @@ @implementation Lession11Cell -+ (CGSize)cellSize:(NSObject *)data bound:(CGSize)bound ++ (CGSize)sizeInBound:(CGSize)bound forData:(NSObject *)data { return CGSizeMake( bound.width, 60.0f ); } -- (void)cellLayout:(BeeUIGridCell *)cell bound:(CGSize)bound +- (void)layoutInBound:(CGSize)bound forCell:(BeeUIGridCell *)cell { _label1.frame = CGRectMake( 10.0f, 5.0f, cell.bounds.size.width - 20.0f, 30.0f ); _label2.frame = CGRectMake( 10.0f, 32.0f, cell.bounds.size.width - 20.0f, 20.0f ); @@ -45,20 +45,26 @@ - (void)unload [super unload]; } -- (void)bindData:(NSObject *)data +- (void)dataWillChange { - Lession11Record * record = (Lession11Record *)data; - - _label1.text = [NSString stringWithFormat:@"%@. %@", record.rid, record.name]; - _label2.text = record.url; - -// [super bindData:data]; + [super dataWillChange]; } -- (void)clearData +- (void)dataDidChanged { - _label1.text = nil; - _label2.text = nil; + [super dataDidChanged]; + + Lession11Record * record = (Lession11Record *)self.cellData; + if ( record ) + { + _label1.text = [NSString stringWithFormat:@"%@. %@", record.rid, record.name]; + _label2.text = record.url; + } + else + { + _label1.text = nil; + _label2.text = nil; + } } @end @@ -124,7 +130,7 @@ - (void)handleUISignal:(BeeUISignal *)signal [super handleUISignal:signal]; } -- (void)handleBeeUIBoard:(BeeUISignal *)signal +- (void)handleUISignal_BeeUIBoard:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -158,16 +164,9 @@ - (void)handleBeeUIBoard:(BeeUISignal *)signal else if ( [signal is:BeeUIBoard.DID_DISAPPEAR] ) { } - else if ( [signal is:BeeUIBoard.BACK_BUTTON_TOUCHED] ) - { - - } - else if ( [signal is:BeeUIBoard.DONE_BUTTON_TOUCHED] ) - { - } } -- (void)handleBeeUITableBoard:(BeeUISignal *)signal +- (void)handleUISignal_BeeUITableBoard:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -204,7 +203,8 @@ - (void)handleBeeUITableBoard:(BeeUISignal *)signal - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { Lession11Record * record = (Lession11Record *)[_records objectAtIndex:indexPath.row]; - return [Lession11Cell cellSize:record bound:CGSizeMake( self.view.bounds.size.width, 0.0f )].height; + CGSize bound = CGSizeMake( self.view.bounds.size.width, 0.0f ); + return [Lession11Cell sizeInBound:bound forData:record].height; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section @@ -217,8 +217,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N BeeUITableViewCell * cell = (BeeUITableViewCell *)[self dequeueWithContentClass:[Lession11Cell class]]; if ( cell ) { - Lession11Record * record = (Lession11Record *)[_records objectAtIndex:indexPath.row]; - [cell bindData:record]; + cell.cellData = [_records objectAtIndex:indexPath.row]; return cell; } diff --git a/Example/Lessions/Lession1Board.m b/Example/Lessions/Lession1Board.m index 01819b7..5abe483 100644 --- a/Example/Lessions/Lession1Board.m +++ b/Example/Lessions/Lession1Board.m @@ -15,8 +15,10 @@ - (void)handleUISignal:(BeeUISignal *)signal } // BeeUIBoard signal goes here -- (void)handleBeeUIBoard:(BeeUISignal *)signal +- (void)handleUISignal_BeeUIBoard:(BeeUISignal *)signal { + [super handleUISignal:signal]; + if ( [signal is:BeeUIBoard.CREATE_VIEWS] ) { // 界面创建 diff --git a/Example/Lessions/Lession2Board.m b/Example/Lessions/Lession2Board.m index 67192aa..ff8b744 100644 --- a/Example/Lessions/Lession2Board.m +++ b/Example/Lessions/Lession2Board.m @@ -34,7 +34,6 @@ - (void)dealloc @end - #pragma mark - @implementation Lession2View1 @@ -63,14 +62,12 @@ - (void)dealloc @implementation Lession2Board -// Other signal goes here - (void)handleUISignal:(BeeUISignal *)signal { [super handleUISignal:signal]; } -// BeeUIBoard signal goes here -- (void)handleBeeUIBoard:(BeeUISignal *)signal +- (void)handleUISignal_BeeUIBoard:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -78,7 +75,7 @@ - (void)handleBeeUIBoard:(BeeUISignal *)signal { [self setTitleString:@"Lession 2"]; [self showNavigationBarAnimated:NO]; - + _textView.contentInset = UIEdgeInsetsMake( 0, 0, 44.0f + 20.0f, 0.0f ); CGRect innerFrame; @@ -101,13 +98,13 @@ - (void)handleBeeUIBoard:(BeeUISignal *)signal } // Lession2View1 signal goes here -- (void)handleLession2View1:(BeeUISignal *)signal +- (void)handleUISignal_Lession2View1:(BeeUISignal *)signal { [super handleUISignal:signal]; } // Lession2View2 signal goes here -- (void)handleLession2View2:(BeeUISignal *)signal +- (void)handleUISignal_Lession2View2:(BeeUISignal *)signal { [super handleUISignal:signal]; diff --git a/Example/Lessions/Lession3Board.m b/Example/Lessions/Lession3Board.m index 8422a82..8c79f4e 100644 --- a/Example/Lessions/Lession3Board.m +++ b/Example/Lessions/Lession3Board.m @@ -11,14 +11,12 @@ @implementation Lession3Board DEF_SIGNAL( BACK ); DEF_SIGNAL( ENTER ); -// Other signal goes here - (void)handleUISignal:(BeeUISignal *)signal { [super handleUISignal:signal]; } -// BeeUIBoard signal goes here -- (void)handleBeeUIBoard:(BeeUISignal *)signal +- (void)handleUISignal_BeeUIBoard:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -63,8 +61,7 @@ - (void)handleBeeUIBoard:(BeeUISignal *)signal } } -// Lession3Board signal goes here -- (void)handleLession3Board:(BeeUISignal *)signal +- (void)handleUISignal_Lession3Board:(BeeUISignal *)signal { if ( [signal is:Lession3Board.ENTER] ) { diff --git a/Example/Lessions/Lession4Board.m b/Example/Lessions/Lession4Board.m index e875a34..3dbb62d 100644 --- a/Example/Lessions/Lession4Board.m +++ b/Example/Lessions/Lession4Board.m @@ -16,7 +16,7 @@ - (void)handleUISignal:(BeeUISignal *)signal [super handleUISignal:signal]; } -- (void)handleBeeUIBoard:(BeeUISignal *)signal +- (void)handleUISignal_BeeUIBoard:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -60,7 +60,7 @@ - (void)handleBeeUIBoard:(BeeUISignal *)signal } } -- (void)handleLession4InnerBoard:(BeeUISignal *)signal +- (void)handleUISignal_Lession4InnerBoard:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -86,7 +86,7 @@ - (void)handleUISignal:(BeeUISignal *)signal [super handleUISignal:signal]; } -- (void)handleBeeUIBoard:(BeeUISignal *)signal +- (void)handleUISignal_BeeUIBoard:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -109,7 +109,7 @@ - (void)handleBeeUIBoard:(BeeUISignal *)signal } } -- (void)handleBeeUISegmentedControl:(BeeUISignal *)signal +- (void)handleUISignal_BeeUISegmentedControl:(BeeUISignal *)signal { if ( [signal is:BeeUISegmentedControl.HIGHLIGHT_CHANGED] ) { diff --git a/Example/Lessions/Lession5Board.h b/Example/Lessions/Lession5Board.h index 471064e..5549ca3 100644 --- a/Example/Lessions/Lession5Board.h +++ b/Example/Lessions/Lession5Board.h @@ -3,6 +3,7 @@ // #import "Bee.h" +#import "Bee_UITableBoard.h" #pragma mark - diff --git a/Example/Lessions/Lession5Board.m b/Example/Lessions/Lession5Board.m index afb289c..277f2cb 100644 --- a/Example/Lessions/Lession5Board.m +++ b/Example/Lessions/Lession5Board.m @@ -11,12 +11,12 @@ @implementation Lession5CellLayout1 DEF_SINGLETON(Lession5CellLayout1) -+ (CGSize)cellSize:(NSObject *)data bound:(CGSize)bound ++ (CGSize)sizeInBound:(CGSize)bound forData:(NSObject *)data { return CGSizeMake( bound.width, 100.0f ); } -- (void)cellLayout:(BeeUIGridCell *)cell bound:(CGSize)bound +- (void)layoutInBound:(CGSize)bound forCell:(BeeUIGridCell *)cell { CGRect photoFrame; photoFrame.origin = CGPointZero; @@ -36,12 +36,12 @@ @implementation Lession5CellLayout2 DEF_SINGLETON(Lession5CellLayout2) -+ (CGSize)cellSize:(NSObject *)data bound:(CGSize)bound ++ (CGSize)sizeInBound:(CGSize)bound forData:(NSObject *)data { return CGSizeMake( bound.width, 200.0f ); } -- (void)cellLayout:(BeeUIGridCell *)cell bound:(CGSize)bound +- (void)layoutInBound:(CGSize)bound forCell:(BeeUIGridCell *)cell { CGRect photoFrame; photoFrame.origin = CGPointZero; @@ -106,20 +106,25 @@ - (void)unload [super unload]; } -- (void)bindData:(NSObject *)data +- (void)dataWillChange { - _photo1.url = @"http://dribbble.s3.amazonaws.com/users/2862/screenshots/802586/asiabear.jpg"; - _photo2.url = @"http://dribbble.s3.amazonaws.com/users/91300/screenshots/802850/d109_dark_side_buddy.jpg"; - _photo3.url = @"http://dribbble.s3.amazonaws.com/users/161397/screenshots/802804/screen_shot_2012-11-06_at_9.20.44_am.png"; - - [super bindData:data]; + [super dataWillChange]; } -- (void)clearData +- (void)dataDidChanged { - _photo1.image = nil; - _photo2.image = nil; - _photo3.image = nil; + if ( self.cellData ) + { + _photo1.url = @"http://dribbble.s3.amazonaws.com/users/2862/screenshots/802586/asiabear.jpg"; + _photo2.url = @"http://dribbble.s3.amazonaws.com/users/91300/screenshots/802850/d109_dark_side_buddy.jpg"; + _photo3.url = @"http://dribbble.s3.amazonaws.com/users/161397/screenshots/802804/screen_shot_2012-11-06_at_9.20.44_am.png"; + } + else + { + _photo1.image = nil; + _photo2.image = nil; + _photo3.image = nil; + } } @end @@ -162,7 +167,7 @@ - (void)handleUISignal:(BeeUISignal *)signal [super handleUISignal:signal]; } -- (void)handleBeeUIBoard:(BeeUISignal *)signal +- (void)handleUISignal_BeeUIBoard:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -183,13 +188,6 @@ - (void)handleBeeUIBoard:(BeeUISignal *)signal else if ( [signal is:BeeUIBoard.DID_DISAPPEAR] ) { } - else if ( [signal is:BeeUIBoard.BACK_BUTTON_TOUCHED] ) - { - - } - else if ( [signal is:BeeUIBoard.DONE_BUTTON_TOUCHED] ) - { - } } #pragma mark - @@ -200,12 +198,12 @@ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPa if ( 0 == [data intValue] ) { CGSize bound = CGSizeMake( self.view.bounds.size.width, 0.0f ); - return [Lession5CellLayout1 cellSize:data bound:bound].height; + return [Lession5CellLayout1 sizeInBound:bound forData:data].height; } else { CGSize bound = CGSizeMake( self.view.bounds.size.width, 0.0f ); - return [Lession5CellLayout2 cellSize:data bound:bound].height; + return [Lession5CellLayout2 sizeInBound:bound forData:data].height; } } @@ -222,13 +220,14 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N NSNumber * data = [_datas objectAtIndex:indexPath.row]; if ( 0 == [data intValue] ) { - [cell.innerCell setLayout:[Lession5CellLayout1 sharedInstance]]; + cell.cellLayout = [Lession5CellLayout1 sharedInstance]; } else { - [cell.innerCell setLayout:[Lession5CellLayout2 sharedInstance]]; + cell.cellLayout = [Lession5CellLayout2 sharedInstance]; } - [cell bindData:data]; + + cell.cellData = data; return cell; } diff --git a/Example/Lessions/Lession6Board.h b/Example/Lessions/Lession6Board.h index f553937..abb598e 100644 --- a/Example/Lessions/Lession6Board.h +++ b/Example/Lessions/Lession6Board.h @@ -3,6 +3,7 @@ // #import "Bee.h" +#import "Bee_UIFlowBoard.h" #pragma mark - diff --git a/Example/Lessions/Lession6Board.m b/Example/Lessions/Lession6Board.m index 922b92a..6f6c74e 100644 --- a/Example/Lessions/Lession6Board.m +++ b/Example/Lessions/Lession6Board.m @@ -8,13 +8,13 @@ @implementation Lession6Cell -+ (CGSize)cellSize:(NSObject *)data bound:(CGSize)bound ++ (CGSize)sizeInBound:(CGSize)bound forData:(NSObject *)data { NSNumber * height = (NSNumber *)[(NSArray *)data objectAtIndex:0]; return CGSizeMake( bound.width, height.floatValue ); } -- (void)cellLayout:(BeeUIGridCell *)cell bound:(CGSize)bound +- (void)layoutInBound:(CGSize)bound forCell:(BeeUIGridCell *)cell { CGRect photoFrame; photoFrame.origin = CGPointZero; @@ -46,19 +46,21 @@ - (void)unload [super unload]; } -- (void)bindData:(NSObject *)data +- (void)dataWillChange { -PERF_ENTER_(1) - _photo.url = (NSString *)[(NSArray *)data objectAtIndex:1]; -PERF_LEAVE_(1) -PERF_ENTER_(2) - [super bindData:data]; -PERF_LEAVE_(2) + [super dataWillChange]; } -- (void)clearData +- (void)dataDidChanged { - _photo.image = nil; + if ( self.cellData ) + { + _photo.url = (NSString *)[(NSArray *)self.cellData objectAtIndex:1]; + } + else + { + _photo.image = nil; + } } @end @@ -100,7 +102,7 @@ - (void)handleUISignal:(BeeUISignal *)signal [super handleUISignal:signal]; } -- (void)handleBeeUIBoard:(BeeUISignal *)signal +- (void)handleUISignal_BeeUIBoard:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -122,13 +124,6 @@ - (void)handleBeeUIBoard:(BeeUISignal *)signal else if ( [signal is:BeeUIBoard.DID_DISAPPEAR] ) { } - else if ( [signal is:BeeUIBoard.BACK_BUTTON_TOUCHED] ) - { - - } - else if ( [signal is:BeeUIBoard.DONE_BUTTON_TOUCHED] ) - { - } } #pragma mark - @@ -149,7 +144,7 @@ - (UIView *)viewForIndex:(NSInteger)index scale:(CGFloat)scale Lession6Cell * cell = (Lession6Cell *)[self dequeueWithContentClass:[Lession6Cell class]]; if ( cell ) { - [cell bindData:data]; + cell.cellData = data; } return cell; } diff --git a/Example/Lessions/Lession7Board.h b/Example/Lessions/Lession7Board.h index 1bf77be..fd9f687 100644 --- a/Example/Lessions/Lession7Board.h +++ b/Example/Lessions/Lession7Board.h @@ -3,6 +3,7 @@ // #import "Bee.h" +#import "Bee_UITableBoard.h" #pragma mark - diff --git a/Example/Lessions/Lession7Board.m b/Example/Lessions/Lession7Board.m index 53dda74..444f696 100644 --- a/Example/Lessions/Lession7Board.m +++ b/Example/Lessions/Lession7Board.m @@ -8,12 +8,12 @@ @implementation Lession7Cell -+ (CGSize)cellSize:(NSObject *)data bound:(CGSize)bound ++ (CGSize)sizeInBound:(CGSize)bound forData:(NSObject *)data { return CGSizeMake( bound.width, 60.0f ); } -- (void)cellLayout:(BeeUIGridCell *)cell bound:(CGSize)bound +- (void)layoutInBound:(CGSize)bound forCell:(BeeUIGridCell *)cell { _title.frame = CGRectMake( 10.0f, 5.0f, cell.bounds.size.width - 20.0f, bound.height - 10.0f ); } @@ -36,16 +36,23 @@ - (void)unload [super unload]; } -- (void)bindData:(NSObject *)data +- (void)dataWillChange { - [_title setText:[(NSArray *)data objectAtIndex:1]]; - - [super bindData:data]; + [super dataWillChange]; } -- (void)clearData +- (void)dataDidChanged { - [_title setText:nil]; + [super dataDidChanged]; + + if ( self.cellData ) + { + [_title setText:[(NSArray *)self.cellData objectAtIndex:1]]; + } + else + { + [_title setText:nil]; + } } @end @@ -92,7 +99,7 @@ - (void)handleUISignal:(BeeUISignal *)signal [super handleUISignal:signal]; } -- (void)handleBeeUIBoard:(BeeUISignal *)signal +- (void)handleUISignal_BeeUIBoard:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -114,7 +121,7 @@ - (void)handleBeeUIBoard:(BeeUISignal *)signal - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { CGSize bound = CGSizeMake( self.view.bounds.size.width, 0.0f ); - return [Lession7Cell cellSize:nil bound:bound].height; + return [Lession7Cell sizeInBound:bound forData:nil].height; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section @@ -129,16 +136,17 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N { if ( indexPath.row % 2 ) { - [cell.innerCell setBackgroundColor:[UIColor whiteColor]]; + cell.backgroundColor = [UIColor whiteColor]; } else { - [cell.innerCell setBackgroundColor:[UIColor colorWithWhite:0.95f alpha:1.0f]]; + cell.backgroundColor = [UIColor colorWithWhite:0.95f alpha:1.0f]; } [cell setSelectionStyle:UITableViewCellSelectionStyleGray]; [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator]; - [cell bindData:[_items objectAtIndex:indexPath.row]]; + + cell.cellData = [_items objectAtIndex:indexPath.row]; return cell; } return [super tableView:tableView cellForRowAtIndexPath:indexPath]; diff --git a/Example/Lessions/Lession7_1Board.m b/Example/Lessions/Lession7_1Board.m index 3cd6a0d..b898891 100644 --- a/Example/Lessions/Lession7_1Board.m +++ b/Example/Lessions/Lession7_1Board.m @@ -27,7 +27,7 @@ - (void)handleUISignal:(BeeUISignal *)signal [super handleUISignal:signal]; } -- (void)handleBeeUIBoard:(BeeUISignal *)signal +- (void)handleUISignal_BeeUIBoard:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -60,7 +60,7 @@ - (void)handleBeeUIBoard:(BeeUISignal *)signal } } -- (void)handleLession7_1Board:(BeeUISignal *)signal +- (void)handleUISignal_Lession7_1Board:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -85,7 +85,7 @@ - (void)handleLession7_1Board:(BeeUISignal *)signal } } -- (void)handleBeeUIActionSheet:(BeeUISignal *)signal +- (void)handleUISignal_BeeUIActionSheet:(BeeUISignal *)signal { [super handleUISignal:signal]; diff --git a/Example/Lessions/Lession7_2Board.m b/Example/Lessions/Lession7_2Board.m index ecee62e..ff7a1c4 100644 --- a/Example/Lessions/Lession7_2Board.m +++ b/Example/Lessions/Lession7_2Board.m @@ -26,7 +26,7 @@ - (void)handleUISignal:(BeeUISignal *)signal [super handleUISignal:signal]; } -- (void)handleBeeUIBoard:(BeeUISignal *)signal +- (void)handleUISignal_BeeUIBoard:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -82,8 +82,10 @@ - (void)handleBeeUIBoard:(BeeUISignal *)signal } } -- (void)handleLession7_2Board:(BeeUISignal *)signal +- (void)handleUISignal_Lession7_2Board:(BeeUISignal *)signal { + [super handleUISignal:signal]; + if ( [signal is:Lession7_2Board.SHOW] ) { [_indicator startAnimating]; diff --git a/Example/Lessions/Lession7_3Board.m b/Example/Lessions/Lession7_3Board.m index 179c56c..3f958b0 100644 --- a/Example/Lessions/Lession7_3Board.m +++ b/Example/Lessions/Lession7_3Board.m @@ -27,7 +27,7 @@ - (void)handleUISignal:(BeeUISignal *)signal [super handleUISignal:signal]; } -- (void)handleBeeUIBoard:(BeeUISignal *)signal +- (void)handleUISignal_BeeUIBoard:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -60,7 +60,7 @@ - (void)handleBeeUIBoard:(BeeUISignal *)signal } } -- (void)handleLession7_3Board:(BeeUISignal *)signal +- (void)handleUISignal_Lession7_3Board:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -88,7 +88,7 @@ - (void)handleLession7_3Board:(BeeUISignal *)signal } } -- (void)handleBeeUIAlertView:(BeeUISignal *)signal +- (void)handleUISignal_BeeUIAlertView:(BeeUISignal *)signal { if ( [signal isKindOf:BeeUIAlertView.SIGNAL] ) { diff --git a/Example/Lessions/Lession7_4Board.m b/Example/Lessions/Lession7_4Board.m index f6d1bbe..4d71c50 100644 --- a/Example/Lessions/Lession7_4Board.m +++ b/Example/Lessions/Lession7_4Board.m @@ -25,7 +25,7 @@ - (void)handleUISignal:(BeeUISignal *)signal [super handleUISignal:signal]; } -- (void)handleBeeUIBoard:(BeeUISignal *)signal +- (void)handleUISignal_BeeUIBoard:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -60,7 +60,7 @@ - (void)handleBeeUIBoard:(BeeUISignal *)signal } } -- (void)handleLession7_4Board:(BeeUISignal *)signal +- (void)handleUISignal_Lession7_4Board:(BeeUISignal *)signal { if ( [signal is:Lession7_4Board.BUTTON_TOUCHED] ) { diff --git a/Example/Lessions/Lession7_5Board.m b/Example/Lessions/Lession7_5Board.m index 3fa40a9..b86e41e 100644 --- a/Example/Lessions/Lession7_5Board.m +++ b/Example/Lessions/Lession7_5Board.m @@ -25,7 +25,7 @@ - (void)handleUISignal:(BeeUISignal *)signal [super handleUISignal:signal]; } -- (void)handleBeeUIBoard:(BeeUISignal *)signal +- (void)handleUISignal_BeeUIBoard:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -69,7 +69,7 @@ - (void)handleBeeUIBoard:(BeeUISignal *)signal } -- (void)handleLession7_5Board:(BeeUISignal *)signal +- (void)handleUISignal_Lession7_5Board:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -81,7 +81,7 @@ - (void)handleLession7_5Board:(BeeUISignal *)signal } } -- (void)handleBeeUIDatePicker:(BeeUISignal *)signal +- (void)handleUISignal_BeeUIDatePicker:(BeeUISignal *)signal { if ( [signal isKindOf:BeeUIDatePicker.SIGNAL] ) { diff --git a/Example/Lessions/Lession7_7Board.m b/Example/Lessions/Lession7_7Board.m index f654137..6f06598 100644 --- a/Example/Lessions/Lession7_7Board.m +++ b/Example/Lessions/Lession7_7Board.m @@ -23,7 +23,7 @@ - (void)handleUISignal:(BeeUISignal *)signal [super handleUISignal:signal]; } -- (void)handleBeeUIBoard:(BeeUISignal *)signal +- (void)handleUISignal_BeeUIBoard:(BeeUISignal *)signal { if ( [signal isKindOf:BeeUIBoard.SIGNAL] ) { diff --git a/Example/Lessions/Lession8Board.m b/Example/Lessions/Lession8Board.m index a2b39a3..89bf497 100644 --- a/Example/Lessions/Lession8Board.m +++ b/Example/Lessions/Lession8Board.m @@ -25,7 +25,7 @@ - (void)handleUISignal:(BeeUISignal *)signal [super handleUISignal:signal]; } -- (void)handleBeeUIBoard:(BeeUISignal *)signal +- (void)handleUISignal_BeeUIBoard:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -62,16 +62,20 @@ - (void)handleBeeUIBoard:(BeeUISignal *)signal else if ( [signal is:BeeUIBoard.DID_DISAPPEAR] ) { } - else if ( [signal is:BeeUIBoard.BACK_BUTTON_TOUCHED] ) +} + +- (void)handleUISignal_UINavigationBar:(BeeUISignal *)signal +{ + if ( [signal is:UINavigationBar.BACK_BUTTON_TOUCHED] ) { } - else if ( [signal is:BeeUIBoard.DONE_BUTTON_TOUCHED] ) + else if ( [signal is:UINavigationBar.DONE_BUTTON_TOUCHED] ) { - } + } } -- (void)handleLession8Board:(BeeUISignal *)signal +- (void)handleUISignal_Lession8Board:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -83,8 +87,7 @@ - (void)handleLession8Board:(BeeUISignal *)signal } else { - [self GET:@"http://blog.whatsbug.com"]; -// [self POST: data:]; + [self HTTP_GET:@"http://blog.whatsbug.com"]; } } } @@ -144,13 +147,13 @@ - (void)handleRequest:(BeeRequest *)request { // TODO: 正在发送数据,更新百分比 - self.title = [NSString stringWithFormat:@"Sending(%d%%)", request.uploadPercent]; + self.title = [NSString stringWithFormat:@"Sending(%f%%)", request.uploadPercent]; } else if ( request.recvProgressed ) { // TODO: 正在接收数据,更新百分比 - self.title = [NSString stringWithFormat:@"Receiving(%d%%)", request.downloadPercent]; + self.title = [NSString stringWithFormat:@"Receiving(%f%%)", request.downloadPercent]; } } } diff --git a/Example/Lessions/Lession9Board.m b/Example/Lessions/Lession9Board.m index 6417881..722fcd9 100644 --- a/Example/Lessions/Lession9Board.m +++ b/Example/Lessions/Lession9Board.m @@ -28,7 +28,7 @@ - (void)handleUISignal:(BeeUISignal *)signal [super handleUISignal:signal]; } -- (void)handleBeeUIBoard:(BeeUISignal *)signal +- (void)handleUISignal_BeeUIBoard:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -75,16 +75,9 @@ - (void)handleBeeUIBoard:(BeeUISignal *)signal else if ( [signal is:BeeUIBoard.DID_DISAPPEAR] ) { } - else if ( [signal is:BeeUIBoard.BACK_BUTTON_TOUCHED] ) - { - - } - else if ( [signal is:BeeUIBoard.DONE_BUTTON_TOUCHED] ) - { - } } -- (void)handleLession9Board:(BeeUISignal *)signal +- (void)handleUISignal_Lession9Board:(BeeUISignal *)signal { [super handleUISignal:signal]; @@ -118,7 +111,7 @@ - (void)handleMessage:(BeeMessage *)msg [super handleMessage:msg]; } -- (void)handleLession9Controller:(BeeMessage *)msg +- (void)handleMessage_Lession9Controller:(BeeMessage *)msg { [super handleMessage:msg]; diff --git a/Example/Lessions/Lession9Controller.m b/Example/Lessions/Lession9Controller.m index bb235df..df52ba7 100644 --- a/Example/Lessions/Lession9Controller.m +++ b/Example/Lessions/Lession9Controller.m @@ -31,11 +31,10 @@ - (void)LOCAL:(BeeMessage *)msg { if ( msg.sending ) { - [msg output: - @"key1", @"value1", - @"key2", @"value2", - @"key3", @"value3", - nil]; + msg + .OUTPUT( @"key1", @"value1" ) + .OUTPUT( @"key2", @"value2" ) + .OUTPUT( @"key3", @"value3" ); msg.succeed = YES; } @@ -71,13 +70,12 @@ - (void)REMOTE:(BeeMessage *)msg } else { - [msg GET:url]; + msg.HTTP_GET( url ); } } else if ( msg.succeed ) { - NSString * httpResponse = [NSString stringWithUTF8String:[msg.response bytes]]; - [msg output:@"response", httpResponse, nil]; + msg.OUTPUT( @"response", msg.responseString ); } else if ( msg.failed ) { diff --git a/Example/Lessions/LessionBaseBoard.m b/Example/Lessions/LessionBaseBoard.m index 075daaa..ef62691 100644 --- a/Example/Lessions/LessionBaseBoard.m +++ b/Example/Lessions/LessionBaseBoard.m @@ -40,7 +40,7 @@ - (void)updateText for ( NSUInteger i = 0; i < self.signals.count; ++i ) { BeeUISignal * signal = [self.signals objectAtIndex:i]; - [text appendFormat:@"[%d] %@\n", self.signalSeq, signal.name]; + [text appendFormat:@"[%d] %@\n", self.signalSeq - i, signal.name]; } _textView.text = text; diff --git a/Example/WhatsBug.xcodeproj/project.pbxproj b/Example/WhatsBug.xcodeproj/project.pbxproj index 2e0fc06..fe1641f 100644 --- a/Example/WhatsBug.xcodeproj/project.pbxproj +++ b/Example/WhatsBug.xcodeproj/project.pbxproj @@ -7,27 +7,117 @@ objects = { /* Begin PBXBuildFile section */ - 63133C7815D4E5F0009A5BFC /* Bee_Debug.m in Sources */ = {isa = PBXBuildFile; fileRef = 63133C5B15D4E5F0009A5BFC /* Bee_Debug.m */; }; - 63133C7E15D4E5F0009A5BFC /* Bee_DebugMessageBoard.m in Sources */ = {isa = PBXBuildFile; fileRef = 63133C6715D4E5F0009A5BFC /* Bee_DebugMessageBoard.m */; }; - 63133C7F15D4E5F0009A5BFC /* Bee_DebugDetailView.m in Sources */ = {isa = PBXBuildFile; fileRef = 63133C6915D4E5F0009A5BFC /* Bee_DebugDetailView.m */; }; - 63133C8015D4E5F0009A5BFC /* Bee_DebugPieView.m in Sources */ = {isa = PBXBuildFile; fileRef = 63133C6B15D4E5F0009A5BFC /* Bee_DebugPieView.m */; }; - 63133C8115D4E5F0009A5BFC /* Bee_DebugPlotsView.m in Sources */ = {isa = PBXBuildFile; fileRef = 63133C6D15D4E5F0009A5BFC /* Bee_DebugPlotsView.m */; }; - 63133C8215D4E5F0009A5BFC /* Bee_DebugSampleView.m in Sources */ = {isa = PBXBuildFile; fileRef = 63133C6F15D4E5F0009A5BFC /* Bee_DebugSampleView.m */; }; - 63133C8415D4E5F0009A5BFC /* Bee_DebugWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 63133C7315D4E5F0009A5BFC /* Bee_DebugWindow.m */; }; - 63133C8515D4E5F0009A5BFC /* bug@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 63133C7415D4E5F0009A5BFC /* bug@2x.png */; }; - 63133C8615D4E5F0009A5BFC /* close@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 63133C7515D4E5F0009A5BFC /* close@2x.png */; }; - 63133C8715D4E5F0009A5BFC /* file@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 63133C7615D4E5F0009A5BFC /* file@2x.png */; }; - 63133C8815D4E5F0009A5BFC /* folder@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 63133C7715D4E5F0009A5BFC /* folder@2x.png */; }; - 63133C9115D8A7A3009A5BFC /* Bee_DebugSandboxBoard.m in Sources */ = {isa = PBXBuildFile; fileRef = 63133C9015D8A7A2009A5BFC /* Bee_DebugSandboxBoard.m */; }; - 63133C9415D8B39C009A5BFC /* Bee_DebugUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = 63133C9315D8B39B009A5BFC /* Bee_DebugUtility.m */; }; - 63133C9D15D8BF1E009A5BFC /* Bee_DebugNetworkBoard.m in Sources */ = {isa = PBXBuildFile; fileRef = 63133C9C15D8BF1A009A5BFC /* Bee_DebugNetworkBoard.m */; }; 631600B1158B62410060743E /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 631600B0158B62410060743E /* libz.dylib */; }; 631600B9158B625A0060743E /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 631600B8158B62590060743E /* QuartzCore.framework */; }; 631600C1158B62720060743E /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 631600C0158B62720060743E /* CFNetwork.framework */; }; 631600C3158B627A0060743E /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 631600C2158B627A0060743E /* SystemConfiguration.framework */; }; 631600C7158B628D0060743E /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 631600C6158B628C0060743E /* Security.framework */; }; - 633F6DFC166A7D870079B3C9 /* Bee_DatabaseTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 633F6DFB166A7D860079B3C9 /* Bee_DatabaseTest.m */; }; - 633F6DFF166B88EA0079B3C9 /* Bee_ActiveRecordTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 633F6DFE166B88EA0079B3C9 /* Bee_ActiveRecordTest.m */; }; + 633EFE05168461BD00F1B27A /* iPad.xib in Resources */ = {isa = PBXBuildFile; fileRef = 633EFE04168461BD00F1B27A /* iPad.xib */; }; + 633EFE07168461D200F1B27A /* iPhone.xib in Resources */ = {isa = PBXBuildFile; fileRef = 633EFE06168461D200F1B27A /* iPhone.xib */; }; + 63513E5016A54436003422CA /* Bee_Foundation.mm in Sources */ = {isa = PBXBuildFile; fileRef = 63513D3516A54436003422CA /* Bee_Foundation.mm */; }; + 63513E5116A54436003422CA /* Bee_Log.mm in Sources */ = {isa = PBXBuildFile; fileRef = 63513D3716A54436003422CA /* Bee_Log.mm */; }; + 63513E5216A54436003422CA /* Bee_Performance.mm in Sources */ = {isa = PBXBuildFile; fileRef = 63513D3916A54436003422CA /* Bee_Performance.mm */; }; + 63513E5316A54436003422CA /* Bee_Runtime.mm in Sources */ = {isa = PBXBuildFile; fileRef = 63513D3B16A54436003422CA /* Bee_Runtime.mm */; }; + 63513E5416A54436003422CA /* Bee_Sandbox.mm in Sources */ = {isa = PBXBuildFile; fileRef = 63513D3D16A54436003422CA /* Bee_Sandbox.mm */; }; + 63513E5516A54436003422CA /* Bee_Singleton.mm in Sources */ = {isa = PBXBuildFile; fileRef = 63513D3F16A54436003422CA /* Bee_Singleton.mm */; }; + 63513E5616A54436003422CA /* Bee_SystemInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D4116A54436003422CA /* Bee_SystemInfo.m */; }; + 63513E5716A54436003422CA /* Bee_Thread.mm in Sources */ = {isa = PBXBuildFile; fileRef = 63513D4316A54436003422CA /* Bee_Thread.mm */; }; + 63513E5816A54436003422CA /* NSArray+BeeExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D4616A54436003422CA /* NSArray+BeeExtension.m */; }; + 63513E5916A54436003422CA /* NSData+BeeExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D4816A54436003422CA /* NSData+BeeExtension.m */; }; + 63513E5A16A54436003422CA /* NSDate+BeeExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D4A16A54436003422CA /* NSDate+BeeExtension.m */; }; + 63513E5B16A54436003422CA /* NSDictionary+BeeExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D4C16A54436003422CA /* NSDictionary+BeeExtension.m */; }; + 63513E5C16A54436003422CA /* NSNumber+BeeExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D4E16A54436003422CA /* NSNumber+BeeExtension.m */; }; + 63513E5D16A54436003422CA /* NSObject+BeeNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D5016A54436003422CA /* NSObject+BeeNotification.m */; }; + 63513E5E16A54436003422CA /* NSObject+BeeProperty.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D5216A54436003422CA /* NSObject+BeeProperty.m */; }; + 63513E5F16A54436003422CA /* NSObject+BeeTicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D5416A54436003422CA /* NSObject+BeeTicker.m */; }; + 63513E6016A54436003422CA /* NSObject+BeeTypeConversion.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D5616A54436003422CA /* NSObject+BeeTypeConversion.m */; }; + 63513E6116A54436003422CA /* NSString+BeeExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D5816A54436003422CA /* NSString+BeeExtension.m */; }; + 63513E6216A54436003422CA /* Bee_Network.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D5B16A54436003422CA /* Bee_Network.m */; }; + 63513E6316A54436003422CA /* Bee_Request.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D5D16A54436003422CA /* Bee_Request.m */; }; + 63513E6416A54436003422CA /* Bee_RequestQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D5F16A54436003422CA /* Bee_RequestQueue.m */; }; + 63513E6516A54436003422CA /* NSObject+BeeRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D6216A54436003422CA /* NSObject+BeeRequest.m */; }; + 63513E6616A54436003422CA /* Bee_ActiveBase.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D6516A54436003422CA /* Bee_ActiveBase.m */; }; + 63513E6716A54436003422CA /* Bee_ActiveBaseTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D6616A54436003422CA /* Bee_ActiveBaseTest.m */; }; + 63513E6816A54436003422CA /* Bee_ActiveRecord.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D6816A54436003422CA /* Bee_ActiveRecord.m */; }; + 63513E6916A54436003422CA /* Bee_ActiveRecordTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D6916A54436003422CA /* Bee_ActiveRecordTest.m */; }; + 63513E6A16A54436003422CA /* Bee_Cache.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D6B16A54436003422CA /* Bee_Cache.m */; }; + 63513E6B16A54436003422CA /* Bee_CacheTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D6C16A54436003422CA /* Bee_CacheTest.m */; }; + 63513E6C16A54436003422CA /* Bee_Database.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D6E16A54436003422CA /* Bee_Database.m */; }; + 63513E6D16A54436003422CA /* Bee_DatabaseTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D6F16A54436003422CA /* Bee_DatabaseTest.m */; }; + 63513E6E16A54436003422CA /* Bee_Keychain.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D7116A54436003422CA /* Bee_Keychain.m */; }; + 63513E6F16A54436003422CA /* Bee_KeychainTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D7216A54436003422CA /* Bee_KeychainTest.m */; }; + 63513E7016A54436003422CA /* Bee_Storage.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D7416A54436003422CA /* Bee_Storage.m */; }; + 63513E7116A54436003422CA /* NSObject+BeeDatabase.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D7716A54436003422CA /* NSObject+BeeDatabase.m */; }; + 63513E7216A54436003422CA /* NSObject+BeeKeychain.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D7916A54436003422CA /* NSObject+BeeKeychain.m */; }; + 63513E7316A54436003422CA /* Bee_UnitTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D7C16A54436003422CA /* Bee_UnitTest.m */; }; + 63513E7516A54436003422CA /* Bee_Controller.mm in Sources */ = {isa = PBXBuildFile; fileRef = 63513D8316A54436003422CA /* Bee_Controller.mm */; }; + 63513E7616A54436003422CA /* Bee_Message.mm in Sources */ = {isa = PBXBuildFile; fileRef = 63513D8516A54436003422CA /* Bee_Message.mm */; }; + 63513E7716A54436003422CA /* Bee_MessageQueue.mm in Sources */ = {isa = PBXBuildFile; fileRef = 63513D8716A54436003422CA /* Bee_MessageQueue.mm */; }; + 63513E7816A54436003422CA /* BeeMessage+ActiveRecord.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D8A16A54436003422CA /* BeeMessage+ActiveRecord.m */; }; + 63513E7916A54436003422CA /* BeeMessage+HTTP.mm in Sources */ = {isa = PBXBuildFile; fileRef = 63513D8C16A54436003422CA /* BeeMessage+HTTP.mm */; }; + 63513E7A16A54436003422CA /* BeeMessage+JSON.mm in Sources */ = {isa = PBXBuildFile; fileRef = 63513D8E16A54436003422CA /* BeeMessage+JSON.mm */; }; + 63513E7B16A54436003422CA /* BeeMessage+XML.mm in Sources */ = {isa = PBXBuildFile; fileRef = 63513D9016A54436003422CA /* BeeMessage+XML.mm */; }; + 63513E7C16A54436003422CA /* NSObject+BeeMessage.mm in Sources */ = {isa = PBXBuildFile; fileRef = 63513D9216A54436003422CA /* NSObject+BeeMessage.mm */; }; + 63513E7D16A54436003422CA /* Bee_Model.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D9516A54436003422CA /* Bee_Model.m */; }; + 63513E7E16A54436003422CA /* Bee_UIActionSheet.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D9916A54436003422CA /* Bee_UIActionSheet.m */; }; + 63513E7F16A54436003422CA /* Bee_UIActivityIndicatorView.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D9B16A54436003422CA /* Bee_UIActivityIndicatorView.m */; }; + 63513E8016A54436003422CA /* Bee_UIAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D9D16A54436003422CA /* Bee_UIAlertView.m */; }; + 63513E8116A54436003422CA /* Bee_UIButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513D9F16A54436003422CA /* Bee_UIButton.m */; }; + 63513E8216A54436003422CA /* Bee_UIDatePicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DA116A54436003422CA /* Bee_UIDatePicker.m */; }; + 63513E8316A54436003422CA /* Bee_UIGridCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DA316A54436003422CA /* Bee_UIGridCell.m */; }; + 63513E8416A54436003422CA /* Bee_UIImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DA516A54436003422CA /* Bee_UIImageView.m */; }; + 63513E8516A54436003422CA /* Bee_UIKeyboard.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DA716A54436003422CA /* Bee_UIKeyboard.m */; }; + 63513E8616A54436003422CA /* Bee_UILabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DA916A54436003422CA /* Bee_UILabel.m */; }; + 63513E8716A54436003422CA /* Bee_UIOrientation.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DAB16A54436003422CA /* Bee_UIOrientation.m */; }; + 63513E8816A54436003422CA /* Bee_UIPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DAD16A54436003422CA /* Bee_UIPageControl.m */; }; + 63513E8916A54436003422CA /* Bee_UIProgressView.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DAF16A54436003422CA /* Bee_UIProgressView.m */; }; + 63513E8A16A54436003422CA /* Bee_UIPullLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DB116A54436003422CA /* Bee_UIPullLoader.m */; }; + 63513E8B16A54436003422CA /* Bee_UIScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DB316A54436003422CA /* Bee_UIScrollView.m */; }; + 63513E8C16A54436003422CA /* Bee_UISegmentedControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DB516A54436003422CA /* Bee_UISegmentedControl.m */; }; + 63513E8D16A54436003422CA /* Bee_UISignal.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DB716A54436003422CA /* Bee_UISignal.m */; }; + 63513E8E16A54436003422CA /* Bee_UITabBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DB916A54436003422CA /* Bee_UITabBar.m */; }; + 63513E8F16A54436003422CA /* Bee_UITextField.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DBB16A54436003422CA /* Bee_UITextField.m */; }; + 63513E9016A54436003422CA /* Bee_UITextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DBD16A54436003422CA /* Bee_UITextView.m */; }; + 63513E9116A54436003422CA /* Bee_UITipsView.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DBF16A54436003422CA /* Bee_UITipsView.m */; }; + 63513E9216A54436003422CA /* Bee_UIWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DC116A54436003422CA /* Bee_UIWebView.m */; }; + 63513E9316A54436003422CA /* Bee_UIZoomView.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DC316A54436003422CA /* Bee_UIZoomView.m */; }; + 63513E9416A54436003422CA /* Bee_View.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DC516A54436003422CA /* Bee_View.m */; }; + 63513E9516A54436003422CA /* CGRect+BeeExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DC816A54436003422CA /* CGRect+BeeExtension.m */; }; + 63513E9716A54436003422CA /* UIColor+BeeExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DCC16A54436003422CA /* UIColor+BeeExtension.m */; }; + 63513E9816A54436003422CA /* UIFont+BeeExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DCE16A54436003422CA /* UIFont+BeeExtension.m */; }; + 63513E9916A54436003422CA /* UIImage+BeeExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DD016A54436003422CA /* UIImage+BeeExtension.m */; }; + 63513E9A16A54436003422CA /* UIView+BeeExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DD216A54436003422CA /* UIView+BeeExtension.m */; }; + 63513E9B16A54436003422CA /* UIView+BeeUISignal.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DD416A54436003422CA /* UIView+BeeUISignal.m */; }; + 63513E9C16A54436003422CA /* UIView+HoldGesture.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DD616A54436003422CA /* UIView+HoldGesture.m */; }; + 63513E9D16A54436003422CA /* UIView+PanGesture.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DD816A54436003422CA /* UIView+PanGesture.m */; }; + 63513E9E16A54436003422CA /* UIView+SwipeGesture.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DDA16A54436003422CA /* UIView+SwipeGesture.m */; }; + 63513E9F16A54436003422CA /* UIView+TapGesture.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DDC16A54436003422CA /* UIView+TapGesture.m */; }; + 63513EA016A54436003422CA /* Bee_UIBoard.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DDF16A54436003422CA /* Bee_UIBoard.m */; }; + 63513EA116A54436003422CA /* Bee_UIStack.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DE116A54436003422CA /* Bee_UIStack.m */; }; + 63513EA216A54436003422CA /* Bee_UIStackGroup.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DE316A54436003422CA /* Bee_UIStackGroup.m */; }; + 63513EA316A54436003422CA /* Bee_ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DE516A54436003422CA /* Bee_ViewController.m */; }; + 63513EA416A54436003422CA /* UIViewController+BeeExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DE816A54436003422CA /* UIViewController+BeeExtension.m */; }; + 63513EA516A54436003422CA /* UIViewController+BeeUISignal.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DEA16A54436003422CA /* UIViewController+BeeUISignal.m */; }; + 63513EA616A54436003422CA /* UIViewController+UINavigationBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DEC16A54436003422CA /* UIViewController+UINavigationBar.m */; }; + 63513EAD16A54436003422CA /* ASIAuthenticationDialog.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DFC16A54436003422CA /* ASIAuthenticationDialog.m */; }; + 63513EAE16A54436003422CA /* ASIDataCompressor.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513DFF16A54436003422CA /* ASIDataCompressor.m */; }; + 63513EAF16A54436003422CA /* ASIDataDecompressor.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513E0116A54436003422CA /* ASIDataDecompressor.m */; }; + 63513EB016A54436003422CA /* ASIDownloadCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513E0316A54436003422CA /* ASIDownloadCache.m */; }; + 63513EB116A54436003422CA /* ASIFormDataRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513E0516A54436003422CA /* ASIFormDataRequest.m */; }; + 63513EB216A54436003422CA /* ASIHTTPRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513E0716A54436003422CA /* ASIHTTPRequest.m */; }; + 63513EB316A54436003422CA /* ASIInputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513E0B16A54436003422CA /* ASIInputStream.m */; }; + 63513EB416A54436003422CA /* ASINetworkQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513E0D16A54436003422CA /* ASINetworkQueue.m */; }; + 63513EB516A54436003422CA /* FMDatabase.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513E1116A54436003422CA /* FMDatabase.m */; }; + 63513EB616A54436003422CA /* FMDatabaseAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513E1316A54436003422CA /* FMDatabaseAdditions.m */; }; + 63513EB716A54436003422CA /* FMDatabasePool.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513E1516A54436003422CA /* FMDatabasePool.m */; }; + 63513EB816A54436003422CA /* FMDatabaseQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513E1716A54436003422CA /* FMDatabaseQueue.m */; }; + 63513EB916A54436003422CA /* FMResultSet.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513E1916A54436003422CA /* FMResultSet.m */; }; + 63513EBA16A54436003422CA /* JSONKit.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513E1C16A54436003422CA /* JSONKit.m */; }; + 63513EBB16A54436003422CA /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 63513E1F16A54436003422CA /* Reachability.m */; }; + 63560A5D16AFCA3700F959AA /* Bee_UICameraBoard.m in Sources */ = {isa = PBXBuildFile; fileRef = 63560A5516AFCA3700F959AA /* Bee_UICameraBoard.m */; }; + 63560A5E16AFCA3700F959AA /* Bee_UIFlowBoard.m in Sources */ = {isa = PBXBuildFile; fileRef = 63560A5716AFCA3700F959AA /* Bee_UIFlowBoard.m */; }; + 63560A5F16AFCA3700F959AA /* Bee_UITableBoard.m in Sources */ = {isa = PBXBuildFile; fileRef = 63560A5916AFCA3700F959AA /* Bee_UITableBoard.m */; }; + 63560A6016AFCA3700F959AA /* Bee_UIWebBoard.m in Sources */ = {isa = PBXBuildFile; fileRef = 63560A5B16AFCA3700F959AA /* Bee_UIWebBoard.m */; }; 6392688F164CEF600099625C /* CatelogBoard.m in Sources */ = {isa = PBXBuildFile; fileRef = 63926860164CEF600099625C /* CatelogBoard.m */; }; 63926890164CEF600099625C /* DribbbleBoard.m in Sources */ = {isa = PBXBuildFile; fileRef = 63926862164CEF600099625C /* DribbbleBoard.m */; }; 63926891164CEF600099625C /* DribbbleController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 63926864164CEF600099625C /* DribbbleController.mm */; }; @@ -52,98 +142,36 @@ 639268A5164CEF600099625C /* Lession9Board.m in Sources */ = {isa = PBXBuildFile; fileRef = 6392688A164CEF600099625C /* Lession9Board.m */; }; 639268A6164CEF600099625C /* Lession9Controller.m in Sources */ = {isa = PBXBuildFile; fileRef = 6392688C164CEF600099625C /* Lession9Controller.m */; }; 639268A7164CEF600099625C /* LessionBaseBoard.m in Sources */ = {isa = PBXBuildFile; fileRef = 6392688E164CEF600099625C /* LessionBaseBoard.m */; }; - 639268E3164CF7460099625C /* Bee_UIActionSheet.m in Sources */ = {isa = PBXBuildFile; fileRef = 639268AA164CF7460099625C /* Bee_UIActionSheet.m */; }; - 639268E4164CF7460099625C /* Bee_UIActivityIndicatorView.m in Sources */ = {isa = PBXBuildFile; fileRef = 639268AC164CF7460099625C /* Bee_UIActivityIndicatorView.m */; }; - 639268E5164CF7460099625C /* Bee_UIAlertView.m in Sources */ = {isa = PBXBuildFile; fileRef = 639268AE164CF7460099625C /* Bee_UIAlertView.m */; }; - 639268E6164CF7460099625C /* Bee_UIButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 639268B0164CF7460099625C /* Bee_UIButton.m */; }; - 639268E8164CF7460099625C /* Bee_UIDatePicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 639268B4164CF7460099625C /* Bee_UIDatePicker.m */; }; - 639268EA164CF7460099625C /* Bee_UIGridCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 639268B8164CF7460099625C /* Bee_UIGridCell.m */; }; - 639268EB164CF7460099625C /* Bee_UIImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 639268BA164CF7460099625C /* Bee_UIImageView.m */; }; - 639268EC164CF7460099625C /* Bee_UIKeyboard.m in Sources */ = {isa = PBXBuildFile; fileRef = 639268BC164CF7460099625C /* Bee_UIKeyboard.m */; }; - 639268ED164CF7460099625C /* Bee_UILabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 639268BE164CF7460099625C /* Bee_UILabel.m */; }; - 639268EF164CF7460099625C /* Bee_UIOrientation.m in Sources */ = {isa = PBXBuildFile; fileRef = 639268C2164CF7460099625C /* Bee_UIOrientation.m */; }; - 639268F0164CF7460099625C /* Bee_UIPageControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 639268C4164CF7460099625C /* Bee_UIPageControl.m */; }; - 639268F1164CF7460099625C /* Bee_UIProgressView.m in Sources */ = {isa = PBXBuildFile; fileRef = 639268C6164CF7460099625C /* Bee_UIProgressView.m */; }; - 639268F2164CF7460099625C /* Bee_UIPullLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 639268C8164CF7460099625C /* Bee_UIPullLoader.m */; }; - 639268F4164CF7460099625C /* Bee_UIScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = 639268CC164CF7460099625C /* Bee_UIScrollView.m */; }; - 639268F5164CF7460099625C /* Bee_UISegmentedControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 639268CE164CF7460099625C /* Bee_UISegmentedControl.m */; }; - 639268F6164CF7460099625C /* Bee_UISignal.m in Sources */ = {isa = PBXBuildFile; fileRef = 639268D0164CF7460099625C /* Bee_UISignal.m */; }; - 639268F7164CF7460099625C /* Bee_UITabBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 639268D2164CF7460099625C /* Bee_UITabBar.m */; }; - 639268F8164CF7460099625C /* Bee_UITextField.m in Sources */ = {isa = PBXBuildFile; fileRef = 639268D4164CF7460099625C /* Bee_UITextField.m */; }; - 639268F9164CF7460099625C /* Bee_UITextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 639268D6164CF7460099625C /* Bee_UITextView.m */; }; - 639268FB164CF7460099625C /* Bee_UIWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = 639268DA164CF7460099625C /* Bee_UIWebView.m */; }; - 639268FC164CF7460099625C /* Bee_UIZoomView.m in Sources */ = {isa = PBXBuildFile; fileRef = 639268DC164CF7460099625C /* Bee_UIZoomView.m */; }; - 639268FE164CF7460099625C /* UIView+BeeQuery.m in Sources */ = {isa = PBXBuildFile; fileRef = 639268E0164CF7460099625C /* UIView+BeeQuery.m */; }; - 639268FF164CF7460099625C /* UIView+BeeWireframe.m in Sources */ = {isa = PBXBuildFile; fileRef = 639268E2164CF7460099625C /* UIView+BeeWireframe.m */; }; - 63926902164CFABE0099625C /* UIColor+BeeExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 63926901164CFABC0099625C /* UIColor+BeeExtension.m */; }; - 63926905164CFB470099625C /* UIFont+BeeExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 63926904164CFB460099625C /* UIFont+BeeExtension.m */; }; - 6392690B164CFE510099625C /* CGRect+BeeExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 6392690A164CFE500099625C /* CGRect+BeeExtension.m */; }; - 6392690E164CFFBE0099625C /* UIImage+BeeExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 6392690D164CFFBD0099625C /* UIImage+BeeExtension.m */; }; - 63926911164D1F580099625C /* UIView+BeeBackground.m in Sources */ = {isa = PBXBuildFile; fileRef = 63926910164D1F520099625C /* UIView+BeeBackground.m */; }; - 63926916164D49DC0099625C /* NSDate+BeeExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 63926915164D49D90099625C /* NSDate+BeeExtension.m */; }; - 6392691C164F88D50099625C /* Bee_DebugHeatmapModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 6392691B164F88D50099625C /* Bee_DebugHeatmapModel.m */; }; - 6392692B164F99320099625C /* tap@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6392692A164F99320099625C /* tap@2x.png */; }; - 6392692D164F9CEF0099625C /* heat@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 6392692C164F9CEF0099625C /* heat@2x.png */; }; - 63A6314E16665170006FC6A0 /* Contributors.txt in Resources */ = {isa = PBXBuildFile; fileRef = 63A6314C16665155006FC6A0 /* Contributors.txt */; }; - 63A6314F16665170006FC6A0 /* License.txt in Resources */ = {isa = PBXBuildFile; fileRef = 63A6314D16665163006FC6A0 /* License.txt */; }; - 63A6315D16665311006FC6A0 /* FMDatabase.m in Sources */ = {isa = PBXBuildFile; fileRef = 63A6315316665311006FC6A0 /* FMDatabase.m */; }; - 63A6315E16665311006FC6A0 /* FMDatabaseAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 63A6315516665311006FC6A0 /* FMDatabaseAdditions.m */; }; - 63A6315F16665311006FC6A0 /* FMDatabasePool.m in Sources */ = {isa = PBXBuildFile; fileRef = 63A6315716665311006FC6A0 /* FMDatabasePool.m */; }; - 63A6316016665311006FC6A0 /* FMDatabaseQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = 63A6315916665311006FC6A0 /* FMDatabaseQueue.m */; }; - 63A6316216665311006FC6A0 /* FMResultSet.m in Sources */ = {isa = PBXBuildFile; fileRef = 63A6315C16665311006FC6A0 /* FMResultSet.m */; }; - 63A63165166657D6006FC6A0 /* Bee_Database.m in Sources */ = {isa = PBXBuildFile; fileRef = 63A63164166657D6006FC6A0 /* Bee_Database.m */; }; - 63A63168166657EE006FC6A0 /* Bee_ActiveRecord.m in Sources */ = {isa = PBXBuildFile; fileRef = 63A63167166657EE006FC6A0 /* Bee_ActiveRecord.m */; }; 63A6316A166659BB006FC6A0 /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 63A63169166659B2006FC6A0 /* libsqlite3.dylib */; }; 63A79250157506E700C863F3 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63A7924F157506E700C863F3 /* UIKit.framework */; }; 63A79252157506E700C863F3 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63A79251157506E700C863F3 /* Foundation.framework */; }; - 63AFC78715DB522100100B4F /* Bee_DebugViewBoard.m in Sources */ = {isa = PBXBuildFile; fileRef = 63AFC78615DB522100100B4F /* Bee_DebugViewBoard.m */; }; - 63AFC79D15DE3EA500100B4F /* Bee_DebugMemoryModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 63AFC79C15DE3EA500100B4F /* Bee_DebugMemoryModel.m */; }; - 63AFC7A015DE410300100B4F /* Bee_DebugMessageModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 63AFC79F15DE410200100B4F /* Bee_DebugMessageModel.m */; }; - 63AFC7A315DE457500100B4F /* Bee_DebugNetworkModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 63AFC7A215DE457400100B4F /* Bee_DebugNetworkModel.m */; }; - 63AFC7A615DE475E00100B4F /* Bee_DebugDashBoard.m in Sources */ = {isa = PBXBuildFile; fileRef = 63AFC7A515DE475D00100B4F /* Bee_DebugDashBoard.m */; }; - 63BF232F16535D7F00F4F97C /* ASIAuthenticationDialog.m in Sources */ = {isa = PBXBuildFile; fileRef = 63BF231316535D7F00F4F97C /* ASIAuthenticationDialog.m */; }; - 63BF233016535D7F00F4F97C /* ASIDataCompressor.m in Sources */ = {isa = PBXBuildFile; fileRef = 63BF231616535D7F00F4F97C /* ASIDataCompressor.m */; }; - 63BF233116535D7F00F4F97C /* ASIDataDecompressor.m in Sources */ = {isa = PBXBuildFile; fileRef = 63BF231816535D7F00F4F97C /* ASIDataDecompressor.m */; }; - 63BF233216535D7F00F4F97C /* ASIDownloadCache.m in Sources */ = {isa = PBXBuildFile; fileRef = 63BF231A16535D7F00F4F97C /* ASIDownloadCache.m */; }; - 63BF233316535D7F00F4F97C /* ASIFormDataRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 63BF231C16535D7F00F4F97C /* ASIFormDataRequest.m */; }; - 63BF233416535D7F00F4F97C /* ASIHTTPRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 63BF231E16535D7F00F4F97C /* ASIHTTPRequest.m */; }; - 63BF233516535D7F00F4F97C /* ASIInputStream.m in Sources */ = {isa = PBXBuildFile; fileRef = 63BF232216535D7F00F4F97C /* ASIInputStream.m */; }; - 63BF233616535D7F00F4F97C /* ASINetworkQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = 63BF232416535D7F00F4F97C /* ASINetworkQueue.m */; }; - 63BF233716535D7F00F4F97C /* JSONKit.m in Sources */ = {isa = PBXBuildFile; fileRef = 63BF232816535D7F00F4F97C /* JSONKit.m */; }; - 63BF233816535D7F00F4F97C /* Reachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 63BF232B16535D7F00F4F97C /* Reachability.m */; }; - 63BF2347165360FF00F4F97C /* Bee_Keychain.m in Sources */ = {isa = PBXBuildFile; fileRef = 63BF2346165360FF00F4F97C /* Bee_Keychain.m */; }; - 63C3AC6815F7942600F411F5 /* Bee_Cache.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C3ABFB15F7942600F411F5 /* Bee_Cache.m */; }; - 63C3AC6915F7942600F411F5 /* Bee_Log.mm in Sources */ = {isa = PBXBuildFile; fileRef = 63C3ABFD15F7942600F411F5 /* Bee_Log.mm */; }; - 63C3AC6A15F7942600F411F5 /* Bee_Network.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C3ABFF15F7942600F411F5 /* Bee_Network.m */; }; - 63C3AC6B15F7942600F411F5 /* Bee_Performance.mm in Sources */ = {isa = PBXBuildFile; fileRef = 63C3AC0115F7942600F411F5 /* Bee_Performance.mm */; }; - 63C3AC6C15F7942600F411F5 /* Bee_Runtime.mm in Sources */ = {isa = PBXBuildFile; fileRef = 63C3AC0315F7942600F411F5 /* Bee_Runtime.mm */; }; - 63C3AC6D15F7942600F411F5 /* Bee_Sandbox.mm in Sources */ = {isa = PBXBuildFile; fileRef = 63C3AC0515F7942600F411F5 /* Bee_Sandbox.mm */; }; - 63C3AC6E15F7942600F411F5 /* Bee_Singleton.mm in Sources */ = {isa = PBXBuildFile; fileRef = 63C3AC0715F7942600F411F5 /* Bee_Singleton.mm */; }; - 63C3AC6F15F7942600F411F5 /* Bee_SystemInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C3AC0915F7942600F411F5 /* Bee_SystemInfo.m */; }; - 63C3AC7015F7942600F411F5 /* Bee_Thread.mm in Sources */ = {isa = PBXBuildFile; fileRef = 63C3AC0B15F7942600F411F5 /* Bee_Thread.mm */; }; - 63C3AC7115F7942600F411F5 /* NSArray+BeeExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C3AC0D15F7942600F411F5 /* NSArray+BeeExtension.m */; }; - 63C3AC7215F7942600F411F5 /* NSData+BeeExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C3AC0F15F7942600F411F5 /* NSData+BeeExtension.m */; }; - 63C3AC7315F7942600F411F5 /* NSDictionary+BeeExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C3AC1115F7942600F411F5 /* NSDictionary+BeeExtension.m */; }; - 63C3AC7415F7942600F411F5 /* NSNumber+BeeExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C3AC1315F7942600F411F5 /* NSNumber+BeeExtension.m */; }; - 63C3AC7515F7942600F411F5 /* NSObject+BeeNotification.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C3AC1515F7942600F411F5 /* NSObject+BeeNotification.m */; }; - 63C3AC7615F7942600F411F5 /* NSObject+BeeProperty.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C3AC1715F7942600F411F5 /* NSObject+BeeProperty.m */; }; - 63C3AC7715F7942600F411F5 /* NSObject+BeeTicker.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C3AC1915F7942600F411F5 /* NSObject+BeeTicker.m */; }; - 63C3AC7815F7942600F411F5 /* NSString+BeeExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C3AC1B15F7942600F411F5 /* NSString+BeeExtension.m */; }; - 63C3AC7915F7942600F411F5 /* Bee_Controller.mm in Sources */ = {isa = PBXBuildFile; fileRef = 63C3AC1E15F7942600F411F5 /* Bee_Controller.mm */; }; - 63C3AC7A15F7942600F411F5 /* Bee_Model.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C3AC2015F7942600F411F5 /* Bee_Model.m */; }; - 63C3AC7B15F7942600F411F5 /* Bee_View.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C3AC2215F7942600F411F5 /* Bee_View.m */; }; - 63C3AC9215F7942600F411F5 /* Bee_UIBoard.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C3AC5215F7942600F411F5 /* Bee_UIBoard.m */; }; - 63C3AC9315F7942600F411F5 /* Bee_UIFlowtBoard.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C3AC5415F7942600F411F5 /* Bee_UIFlowtBoard.m */; }; - 63C3AC9415F7942600F411F5 /* Bee_UIStack.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C3AC5615F7942600F411F5 /* Bee_UIStack.m */; }; - 63C3AC9515F7942600F411F5 /* Bee_UIStackGroup.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C3AC5815F7942600F411F5 /* Bee_UIStackGroup.m */; }; - 63C3AC9615F7942600F411F5 /* Bee_UITableBoard.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C3AC5A15F7942600F411F5 /* Bee_UITableBoard.m */; }; - 63C3AC9715F7942600F411F5 /* Bee_UIWebBoard.m in Sources */ = {isa = PBXBuildFile; fileRef = 63C3AC5C15F7942600F411F5 /* Bee_UIWebBoard.m */; }; - 63D5116316593A39005948E3 /* Bee_DebugViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 63D5116216593A38005948E3 /* Bee_DebugViewModel.m */; }; - 63D5116916596495005948E3 /* Bee_DebugCrashReporter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 63D5116816596494005948E3 /* Bee_DebugCrashReporter.mm */; }; + 63B46E8D16A6BC180087C88C /* Bee_Debug.m in Sources */ = {isa = PBXBuildFile; fileRef = 63B46E6416A6BC180087C88C /* Bee_Debug.m */; }; + 63B46E8E16A6BC180087C88C /* Bee_DebugCrashReporter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 63B46E6616A6BC180087C88C /* Bee_DebugCrashReporter.mm */; }; + 63B46E8F16A6BC180087C88C /* Bee_DebugDashBoard.m in Sources */ = {isa = PBXBuildFile; fileRef = 63B46E6816A6BC180087C88C /* Bee_DebugDashBoard.m */; }; + 63B46E9016A6BC180087C88C /* Bee_DebugDetailView.m in Sources */ = {isa = PBXBuildFile; fileRef = 63B46E6A16A6BC180087C88C /* Bee_DebugDetailView.m */; }; + 63B46E9116A6BC180087C88C /* Bee_DebugHeatmapModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 63B46E6C16A6BC180087C88C /* Bee_DebugHeatmapModel.m */; }; + 63B46E9216A6BC180087C88C /* Bee_DebugMemoryModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 63B46E6E16A6BC180087C88C /* Bee_DebugMemoryModel.m */; }; + 63B46E9316A6BC180087C88C /* Bee_DebugMessageBoard.m in Sources */ = {isa = PBXBuildFile; fileRef = 63B46E7016A6BC180087C88C /* Bee_DebugMessageBoard.m */; }; + 63B46E9416A6BC180087C88C /* Bee_DebugMessageModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 63B46E7216A6BC180087C88C /* Bee_DebugMessageModel.m */; }; + 63B46E9516A6BC180087C88C /* Bee_DebugNetworkBoard.m in Sources */ = {isa = PBXBuildFile; fileRef = 63B46E7416A6BC180087C88C /* Bee_DebugNetworkBoard.m */; }; + 63B46E9616A6BC180087C88C /* Bee_DebugNetworkModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 63B46E7616A6BC180087C88C /* Bee_DebugNetworkModel.m */; }; + 63B46E9716A6BC180087C88C /* Bee_DebugPieView.m in Sources */ = {isa = PBXBuildFile; fileRef = 63B46E7816A6BC180087C88C /* Bee_DebugPieView.m */; }; + 63B46E9816A6BC180087C88C /* Bee_DebugPlotsView.m in Sources */ = {isa = PBXBuildFile; fileRef = 63B46E7A16A6BC180087C88C /* Bee_DebugPlotsView.m */; }; + 63B46E9916A6BC180087C88C /* Bee_DebugSampleView.m in Sources */ = {isa = PBXBuildFile; fileRef = 63B46E7C16A6BC180087C88C /* Bee_DebugSampleView.m */; }; + 63B46E9A16A6BC180087C88C /* Bee_DebugSandboxBoard.m in Sources */ = {isa = PBXBuildFile; fileRef = 63B46E7E16A6BC180087C88C /* Bee_DebugSandboxBoard.m */; }; + 63B46E9B16A6BC180087C88C /* Bee_DebugUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = 63B46E8016A6BC180087C88C /* Bee_DebugUtility.m */; }; + 63B46E9C16A6BC180087C88C /* Bee_DebugViewBoard.m in Sources */ = {isa = PBXBuildFile; fileRef = 63B46E8216A6BC180087C88C /* Bee_DebugViewBoard.m */; }; + 63B46E9D16A6BC180087C88C /* Bee_DebugViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 63B46E8416A6BC180087C88C /* Bee_DebugViewModel.m */; }; + 63B46E9E16A6BC180087C88C /* Bee_DebugWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 63B46E8616A6BC180087C88C /* Bee_DebugWindow.m */; }; + 63B46E9F16A6BC180087C88C /* bug@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 63B46E8716A6BC180087C88C /* bug@2x.png */; }; + 63B46EA016A6BC180087C88C /* close@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 63B46E8816A6BC180087C88C /* close@2x.png */; }; + 63B46EA116A6BC180087C88C /* file@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 63B46E8916A6BC180087C88C /* file@2x.png */; }; + 63B46EA216A6BC180087C88C /* folder@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 63B46E8A16A6BC180087C88C /* folder@2x.png */; }; + 63B46EA316A6BC180087C88C /* heat@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 63B46E8B16A6BC180087C88C /* heat@2x.png */; }; + 63B46EA416A6BC180087C88C /* tap@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 63B46E8C16A6BC180087C88C /* tap@2x.png */; }; 63EAE482166E2C5500C6F40E /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 63EAE481166E2C5500C6F40E /* Default-568h@2x.png */; }; 63F5FB6F166CE38B00139103 /* Lession11Board.m in Sources */ = {isa = PBXBuildFile; fileRef = 63F5FB6C166CE38B00139103 /* Lession11Board.m */; }; 63F5FB73166CE53900139103 /* Lession11Model.m in Sources */ = {isa = PBXBuildFile; fileRef = 63F5FB72166CE53900139103 /* Lession11Model.m */; }; - 63F8E90F160C595300A5FECC /* Bee_UICameraBoard.m in Sources */ = {isa = PBXBuildFile; fileRef = 63F8E90E160C595300A5FECC /* Bee_UICameraBoard.m */; }; 63F8E911160C599B00A5FECC /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63F8E910160C599B00A5FECC /* AVFoundation.framework */; }; 63F8E916160C5B6A00A5FECC /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63F8E915160C5B6A00A5FECC /* CoreVideo.framework */; }; 63F8E918160C5B8900A5FECC /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63F8E917160C5B8900A5FECC /* CoreMedia.framework */; }; @@ -158,39 +186,224 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 63133C5A15D4E5F0009A5BFC /* Bee_Debug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Debug.h; sourceTree = ""; }; - 63133C5B15D4E5F0009A5BFC /* Bee_Debug.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_Debug.m; sourceTree = ""; }; - 63133C6615D4E5F0009A5BFC /* Bee_DebugMessageBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugMessageBoard.h; sourceTree = ""; }; - 63133C6715D4E5F0009A5BFC /* Bee_DebugMessageBoard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugMessageBoard.m; sourceTree = ""; }; - 63133C6815D4E5F0009A5BFC /* Bee_DebugDetailView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugDetailView.h; sourceTree = ""; }; - 63133C6915D4E5F0009A5BFC /* Bee_DebugDetailView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugDetailView.m; sourceTree = ""; }; - 63133C6A15D4E5F0009A5BFC /* Bee_DebugPieView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugPieView.h; sourceTree = ""; }; - 63133C6B15D4E5F0009A5BFC /* Bee_DebugPieView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugPieView.m; sourceTree = ""; }; - 63133C6C15D4E5F0009A5BFC /* Bee_DebugPlotsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugPlotsView.h; sourceTree = ""; }; - 63133C6D15D4E5F0009A5BFC /* Bee_DebugPlotsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugPlotsView.m; sourceTree = ""; }; - 63133C6E15D4E5F0009A5BFC /* Bee_DebugSampleView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugSampleView.h; sourceTree = ""; }; - 63133C6F15D4E5F0009A5BFC /* Bee_DebugSampleView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugSampleView.m; sourceTree = ""; }; - 63133C7215D4E5F0009A5BFC /* Bee_DebugWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugWindow.h; sourceTree = ""; }; - 63133C7315D4E5F0009A5BFC /* Bee_DebugWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugWindow.m; sourceTree = ""; }; - 63133C7415D4E5F0009A5BFC /* bug@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "bug@2x.png"; sourceTree = ""; }; - 63133C7515D4E5F0009A5BFC /* close@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "close@2x.png"; sourceTree = ""; }; - 63133C7615D4E5F0009A5BFC /* file@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "file@2x.png"; sourceTree = ""; }; - 63133C7715D4E5F0009A5BFC /* folder@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "folder@2x.png"; sourceTree = ""; }; - 63133C8F15D8A7A2009A5BFC /* Bee_DebugSandboxBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugSandboxBoard.h; sourceTree = ""; }; - 63133C9015D8A7A2009A5BFC /* Bee_DebugSandboxBoard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugSandboxBoard.m; sourceTree = ""; }; - 63133C9215D8B39A009A5BFC /* Bee_DebugUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugUtility.h; sourceTree = ""; }; - 63133C9315D8B39B009A5BFC /* Bee_DebugUtility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugUtility.m; sourceTree = ""; }; - 63133C9B15D8BF18009A5BFC /* Bee_DebugNetworkBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugNetworkBoard.h; sourceTree = ""; }; - 63133C9C15D8BF1A009A5BFC /* Bee_DebugNetworkBoard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugNetworkBoard.m; sourceTree = ""; }; 631600B0158B62410060743E /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; 631600B8158B62590060743E /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 631600C0158B62720060743E /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; }; 631600C2158B627A0060743E /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; }; 631600C6158B628C0060743E /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; - 633F6DFA166A7D860079B3C9 /* Bee_DatabaseTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DatabaseTest.h; sourceTree = ""; }; - 633F6DFB166A7D860079B3C9 /* Bee_DatabaseTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DatabaseTest.m; sourceTree = ""; }; - 633F6DFD166B88EA0079B3C9 /* Bee_ActiveRecordTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_ActiveRecordTest.h; sourceTree = ""; }; - 633F6DFE166B88EA0079B3C9 /* Bee_ActiveRecordTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_ActiveRecordTest.m; sourceTree = ""; }; + 633EFE04168461BD00F1B27A /* iPad.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = iPad.xib; sourceTree = ""; }; + 633EFE06168461D200F1B27A /* iPhone.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = iPhone.xib; sourceTree = ""; }; + 63513D2F16A54436003422CA /* Bee.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee.h; sourceTree = ""; }; + 63513D3016A54436003422CA /* Bee_Precompile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Precompile.h; sourceTree = ""; }; + 63513D3216A54436003422CA /* Bee_Core.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Core.h; sourceTree = ""; }; + 63513D3416A54436003422CA /* Bee_Foundation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Foundation.h; sourceTree = ""; }; + 63513D3516A54436003422CA /* Bee_Foundation.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Bee_Foundation.mm; sourceTree = ""; }; + 63513D3616A54436003422CA /* Bee_Log.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Log.h; sourceTree = ""; }; + 63513D3716A54436003422CA /* Bee_Log.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Bee_Log.mm; sourceTree = ""; }; + 63513D3816A54436003422CA /* Bee_Performance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Performance.h; sourceTree = ""; }; + 63513D3916A54436003422CA /* Bee_Performance.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Bee_Performance.mm; sourceTree = ""; }; + 63513D3A16A54436003422CA /* Bee_Runtime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Runtime.h; sourceTree = ""; }; + 63513D3B16A54436003422CA /* Bee_Runtime.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Bee_Runtime.mm; sourceTree = ""; }; + 63513D3C16A54436003422CA /* Bee_Sandbox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Sandbox.h; sourceTree = ""; }; + 63513D3D16A54436003422CA /* Bee_Sandbox.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Bee_Sandbox.mm; sourceTree = ""; }; + 63513D3E16A54436003422CA /* Bee_Singleton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Singleton.h; sourceTree = ""; }; + 63513D3F16A54436003422CA /* Bee_Singleton.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Bee_Singleton.mm; sourceTree = ""; }; + 63513D4016A54436003422CA /* Bee_SystemInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_SystemInfo.h; sourceTree = ""; }; + 63513D4116A54436003422CA /* Bee_SystemInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_SystemInfo.m; sourceTree = ""; }; + 63513D4216A54436003422CA /* Bee_Thread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Thread.h; sourceTree = ""; }; + 63513D4316A54436003422CA /* Bee_Thread.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Bee_Thread.mm; sourceTree = ""; }; + 63513D4516A54436003422CA /* NSArray+BeeExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+BeeExtension.h"; sourceTree = ""; }; + 63513D4616A54436003422CA /* NSArray+BeeExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+BeeExtension.m"; sourceTree = ""; }; + 63513D4716A54436003422CA /* NSData+BeeExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+BeeExtension.h"; sourceTree = ""; }; + 63513D4816A54436003422CA /* NSData+BeeExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+BeeExtension.m"; sourceTree = ""; }; + 63513D4916A54436003422CA /* NSDate+BeeExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+BeeExtension.h"; sourceTree = ""; }; + 63513D4A16A54436003422CA /* NSDate+BeeExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDate+BeeExtension.m"; sourceTree = ""; }; + 63513D4B16A54436003422CA /* NSDictionary+BeeExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+BeeExtension.h"; sourceTree = ""; }; + 63513D4C16A54436003422CA /* NSDictionary+BeeExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+BeeExtension.m"; sourceTree = ""; }; + 63513D4D16A54436003422CA /* NSNumber+BeeExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSNumber+BeeExtension.h"; sourceTree = ""; }; + 63513D4E16A54436003422CA /* NSNumber+BeeExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSNumber+BeeExtension.m"; sourceTree = ""; }; + 63513D4F16A54436003422CA /* NSObject+BeeNotification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+BeeNotification.h"; sourceTree = ""; }; + 63513D5016A54436003422CA /* NSObject+BeeNotification.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+BeeNotification.m"; sourceTree = ""; }; + 63513D5116A54436003422CA /* NSObject+BeeProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+BeeProperty.h"; sourceTree = ""; }; + 63513D5216A54436003422CA /* NSObject+BeeProperty.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+BeeProperty.m"; sourceTree = ""; }; + 63513D5316A54436003422CA /* NSObject+BeeTicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+BeeTicker.h"; sourceTree = ""; }; + 63513D5416A54436003422CA /* NSObject+BeeTicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+BeeTicker.m"; sourceTree = ""; }; + 63513D5516A54436003422CA /* NSObject+BeeTypeConversion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+BeeTypeConversion.h"; sourceTree = ""; }; + 63513D5616A54436003422CA /* NSObject+BeeTypeConversion.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+BeeTypeConversion.m"; sourceTree = ""; }; + 63513D5716A54436003422CA /* NSString+BeeExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+BeeExtension.h"; sourceTree = ""; }; + 63513D5816A54436003422CA /* NSString+BeeExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+BeeExtension.m"; sourceTree = ""; }; + 63513D5A16A54436003422CA /* Bee_Network.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Network.h; sourceTree = ""; }; + 63513D5B16A54436003422CA /* Bee_Network.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_Network.m; sourceTree = ""; }; + 63513D5C16A54436003422CA /* Bee_Request.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Request.h; sourceTree = ""; }; + 63513D5D16A54436003422CA /* Bee_Request.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_Request.m; sourceTree = ""; }; + 63513D5E16A54436003422CA /* Bee_RequestQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_RequestQueue.h; sourceTree = ""; }; + 63513D5F16A54436003422CA /* Bee_RequestQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_RequestQueue.m; sourceTree = ""; }; + 63513D6116A54436003422CA /* NSObject+BeeRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+BeeRequest.h"; sourceTree = ""; }; + 63513D6216A54436003422CA /* NSObject+BeeRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+BeeRequest.m"; sourceTree = ""; }; + 63513D6416A54436003422CA /* Bee_ActiveBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_ActiveBase.h; sourceTree = ""; }; + 63513D6516A54436003422CA /* Bee_ActiveBase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_ActiveBase.m; sourceTree = ""; }; + 63513D6616A54436003422CA /* Bee_ActiveBaseTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_ActiveBaseTest.m; sourceTree = ""; }; + 63513D6716A54436003422CA /* Bee_ActiveRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_ActiveRecord.h; sourceTree = ""; }; + 63513D6816A54436003422CA /* Bee_ActiveRecord.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_ActiveRecord.m; sourceTree = ""; }; + 63513D6916A54436003422CA /* Bee_ActiveRecordTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_ActiveRecordTest.m; sourceTree = ""; }; + 63513D6A16A54436003422CA /* Bee_Cache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Cache.h; sourceTree = ""; }; + 63513D6B16A54436003422CA /* Bee_Cache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_Cache.m; sourceTree = ""; }; + 63513D6C16A54436003422CA /* Bee_CacheTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_CacheTest.m; sourceTree = ""; }; + 63513D6D16A54436003422CA /* Bee_Database.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Database.h; sourceTree = ""; }; + 63513D6E16A54436003422CA /* Bee_Database.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_Database.m; sourceTree = ""; }; + 63513D6F16A54436003422CA /* Bee_DatabaseTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DatabaseTest.m; sourceTree = ""; }; + 63513D7016A54436003422CA /* Bee_Keychain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Keychain.h; sourceTree = ""; }; + 63513D7116A54436003422CA /* Bee_Keychain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_Keychain.m; sourceTree = ""; }; + 63513D7216A54436003422CA /* Bee_KeychainTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_KeychainTest.m; sourceTree = ""; }; + 63513D7316A54436003422CA /* Bee_Storage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Storage.h; sourceTree = ""; }; + 63513D7416A54436003422CA /* Bee_Storage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_Storage.m; sourceTree = ""; }; + 63513D7616A54436003422CA /* NSObject+BeeDatabase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+BeeDatabase.h"; sourceTree = ""; }; + 63513D7716A54436003422CA /* NSObject+BeeDatabase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+BeeDatabase.m"; sourceTree = ""; }; + 63513D7816A54436003422CA /* NSObject+BeeKeychain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+BeeKeychain.h"; sourceTree = ""; }; + 63513D7916A54436003422CA /* NSObject+BeeKeychain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+BeeKeychain.m"; sourceTree = ""; }; + 63513D7B16A54436003422CA /* Bee_UnitTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UnitTest.h; sourceTree = ""; }; + 63513D7C16A54436003422CA /* Bee_UnitTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UnitTest.m; sourceTree = ""; }; + 63513D8016A54436003422CA /* Bee_MVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_MVC.h; sourceTree = ""; }; + 63513D8216A54436003422CA /* Bee_Controller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Controller.h; sourceTree = ""; }; + 63513D8316A54436003422CA /* Bee_Controller.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Bee_Controller.mm; sourceTree = ""; }; + 63513D8416A54436003422CA /* Bee_Message.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Message.h; sourceTree = ""; }; + 63513D8516A54436003422CA /* Bee_Message.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Bee_Message.mm; sourceTree = ""; }; + 63513D8616A54436003422CA /* Bee_MessageQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_MessageQueue.h; sourceTree = ""; }; + 63513D8716A54436003422CA /* Bee_MessageQueue.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Bee_MessageQueue.mm; sourceTree = ""; }; + 63513D8916A54436003422CA /* BeeMessage+ActiveRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BeeMessage+ActiveRecord.h"; sourceTree = ""; }; + 63513D8A16A54436003422CA /* BeeMessage+ActiveRecord.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "BeeMessage+ActiveRecord.m"; sourceTree = ""; }; + 63513D8B16A54436003422CA /* BeeMessage+HTTP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BeeMessage+HTTP.h"; sourceTree = ""; }; + 63513D8C16A54436003422CA /* BeeMessage+HTTP.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "BeeMessage+HTTP.mm"; sourceTree = ""; }; + 63513D8D16A54436003422CA /* BeeMessage+JSON.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BeeMessage+JSON.h"; sourceTree = ""; }; + 63513D8E16A54436003422CA /* BeeMessage+JSON.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "BeeMessage+JSON.mm"; sourceTree = ""; }; + 63513D8F16A54436003422CA /* BeeMessage+XML.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BeeMessage+XML.h"; sourceTree = ""; }; + 63513D9016A54436003422CA /* BeeMessage+XML.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "BeeMessage+XML.mm"; sourceTree = ""; }; + 63513D9116A54436003422CA /* NSObject+BeeMessage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+BeeMessage.h"; sourceTree = ""; }; + 63513D9216A54436003422CA /* NSObject+BeeMessage.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSObject+BeeMessage.mm"; sourceTree = ""; }; + 63513D9416A54436003422CA /* Bee_Model.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Model.h; sourceTree = ""; }; + 63513D9516A54436003422CA /* Bee_Model.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_Model.m; sourceTree = ""; }; + 63513D9816A54436003422CA /* Bee_UIActionSheet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIActionSheet.h; sourceTree = ""; }; + 63513D9916A54436003422CA /* Bee_UIActionSheet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIActionSheet.m; sourceTree = ""; }; + 63513D9A16A54436003422CA /* Bee_UIActivityIndicatorView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIActivityIndicatorView.h; sourceTree = ""; }; + 63513D9B16A54436003422CA /* Bee_UIActivityIndicatorView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIActivityIndicatorView.m; sourceTree = ""; }; + 63513D9C16A54436003422CA /* Bee_UIAlertView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIAlertView.h; sourceTree = ""; }; + 63513D9D16A54436003422CA /* Bee_UIAlertView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIAlertView.m; sourceTree = ""; }; + 63513D9E16A54436003422CA /* Bee_UIButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIButton.h; sourceTree = ""; }; + 63513D9F16A54436003422CA /* Bee_UIButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIButton.m; sourceTree = ""; }; + 63513DA016A54436003422CA /* Bee_UIDatePicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIDatePicker.h; sourceTree = ""; }; + 63513DA116A54436003422CA /* Bee_UIDatePicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIDatePicker.m; sourceTree = ""; }; + 63513DA216A54436003422CA /* Bee_UIGridCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIGridCell.h; sourceTree = ""; }; + 63513DA316A54436003422CA /* Bee_UIGridCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIGridCell.m; sourceTree = ""; }; + 63513DA416A54436003422CA /* Bee_UIImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIImageView.h; sourceTree = ""; }; + 63513DA516A54436003422CA /* Bee_UIImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIImageView.m; sourceTree = ""; }; + 63513DA616A54436003422CA /* Bee_UIKeyboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIKeyboard.h; sourceTree = ""; }; + 63513DA716A54436003422CA /* Bee_UIKeyboard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIKeyboard.m; sourceTree = ""; }; + 63513DA816A54436003422CA /* Bee_UILabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UILabel.h; sourceTree = ""; }; + 63513DA916A54436003422CA /* Bee_UILabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UILabel.m; sourceTree = ""; }; + 63513DAA16A54436003422CA /* Bee_UIOrientation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIOrientation.h; sourceTree = ""; }; + 63513DAB16A54436003422CA /* Bee_UIOrientation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIOrientation.m; sourceTree = ""; }; + 63513DAC16A54436003422CA /* Bee_UIPageControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIPageControl.h; sourceTree = ""; }; + 63513DAD16A54436003422CA /* Bee_UIPageControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIPageControl.m; sourceTree = ""; }; + 63513DAE16A54436003422CA /* Bee_UIProgressView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIProgressView.h; sourceTree = ""; }; + 63513DAF16A54436003422CA /* Bee_UIProgressView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIProgressView.m; sourceTree = ""; }; + 63513DB016A54436003422CA /* Bee_UIPullLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIPullLoader.h; sourceTree = ""; }; + 63513DB116A54436003422CA /* Bee_UIPullLoader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIPullLoader.m; sourceTree = ""; }; + 63513DB216A54436003422CA /* Bee_UIScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIScrollView.h; sourceTree = ""; }; + 63513DB316A54436003422CA /* Bee_UIScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIScrollView.m; sourceTree = ""; }; + 63513DB416A54436003422CA /* Bee_UISegmentedControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UISegmentedControl.h; sourceTree = ""; }; + 63513DB516A54436003422CA /* Bee_UISegmentedControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UISegmentedControl.m; sourceTree = ""; }; + 63513DB616A54436003422CA /* Bee_UISignal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UISignal.h; sourceTree = ""; }; + 63513DB716A54436003422CA /* Bee_UISignal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UISignal.m; sourceTree = ""; }; + 63513DB816A54436003422CA /* Bee_UITabBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UITabBar.h; sourceTree = ""; }; + 63513DB916A54436003422CA /* Bee_UITabBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UITabBar.m; sourceTree = ""; }; + 63513DBA16A54436003422CA /* Bee_UITextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UITextField.h; sourceTree = ""; }; + 63513DBB16A54436003422CA /* Bee_UITextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UITextField.m; sourceTree = ""; }; + 63513DBC16A54436003422CA /* Bee_UITextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UITextView.h; sourceTree = ""; }; + 63513DBD16A54436003422CA /* Bee_UITextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UITextView.m; sourceTree = ""; }; + 63513DBE16A54436003422CA /* Bee_UITipsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UITipsView.h; sourceTree = ""; }; + 63513DBF16A54436003422CA /* Bee_UITipsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UITipsView.m; sourceTree = ""; }; + 63513DC016A54436003422CA /* Bee_UIWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIWebView.h; sourceTree = ""; }; + 63513DC116A54436003422CA /* Bee_UIWebView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIWebView.m; sourceTree = ""; }; + 63513DC216A54436003422CA /* Bee_UIZoomView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIZoomView.h; sourceTree = ""; }; + 63513DC316A54436003422CA /* Bee_UIZoomView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIZoomView.m; sourceTree = ""; }; + 63513DC416A54436003422CA /* Bee_View.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_View.h; sourceTree = ""; }; + 63513DC516A54436003422CA /* Bee_View.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_View.m; sourceTree = ""; }; + 63513DC716A54436003422CA /* CGRect+BeeExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CGRect+BeeExtension.h"; sourceTree = ""; }; + 63513DC816A54436003422CA /* CGRect+BeeExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "CGRect+BeeExtension.m"; sourceTree = ""; }; + 63513DCB16A54436003422CA /* UIColor+BeeExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+BeeExtension.h"; sourceTree = ""; }; + 63513DCC16A54436003422CA /* UIColor+BeeExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+BeeExtension.m"; sourceTree = ""; }; + 63513DCD16A54436003422CA /* UIFont+BeeExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIFont+BeeExtension.h"; sourceTree = ""; }; + 63513DCE16A54436003422CA /* UIFont+BeeExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIFont+BeeExtension.m"; sourceTree = ""; }; + 63513DCF16A54436003422CA /* UIImage+BeeExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+BeeExtension.h"; sourceTree = ""; }; + 63513DD016A54436003422CA /* UIImage+BeeExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+BeeExtension.m"; sourceTree = ""; }; + 63513DD116A54436003422CA /* UIView+BeeExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+BeeExtension.h"; sourceTree = ""; }; + 63513DD216A54436003422CA /* UIView+BeeExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+BeeExtension.m"; sourceTree = ""; }; + 63513DD316A54436003422CA /* UIView+BeeUISignal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+BeeUISignal.h"; sourceTree = ""; }; + 63513DD416A54436003422CA /* UIView+BeeUISignal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+BeeUISignal.m"; sourceTree = ""; }; + 63513DD516A54436003422CA /* UIView+HoldGesture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+HoldGesture.h"; sourceTree = ""; }; + 63513DD616A54436003422CA /* UIView+HoldGesture.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+HoldGesture.m"; sourceTree = ""; }; + 63513DD716A54436003422CA /* UIView+PanGesture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+PanGesture.h"; sourceTree = ""; }; + 63513DD816A54436003422CA /* UIView+PanGesture.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+PanGesture.m"; sourceTree = ""; }; + 63513DD916A54436003422CA /* UIView+SwipeGesture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+SwipeGesture.h"; sourceTree = ""; }; + 63513DDA16A54436003422CA /* UIView+SwipeGesture.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+SwipeGesture.m"; sourceTree = ""; }; + 63513DDB16A54436003422CA /* UIView+TapGesture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+TapGesture.h"; sourceTree = ""; }; + 63513DDC16A54436003422CA /* UIView+TapGesture.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+TapGesture.m"; sourceTree = ""; }; + 63513DDE16A54436003422CA /* Bee_UIBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIBoard.h; sourceTree = ""; }; + 63513DDF16A54436003422CA /* Bee_UIBoard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIBoard.m; sourceTree = ""; }; + 63513DE016A54436003422CA /* Bee_UIStack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIStack.h; sourceTree = ""; }; + 63513DE116A54436003422CA /* Bee_UIStack.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIStack.m; sourceTree = ""; }; + 63513DE216A54436003422CA /* Bee_UIStackGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIStackGroup.h; sourceTree = ""; }; + 63513DE316A54436003422CA /* Bee_UIStackGroup.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIStackGroup.m; sourceTree = ""; }; + 63513DE416A54436003422CA /* Bee_ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_ViewController.h; sourceTree = ""; }; + 63513DE516A54436003422CA /* Bee_ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_ViewController.m; sourceTree = ""; }; + 63513DE716A54436003422CA /* UIViewController+BeeExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+BeeExtension.h"; sourceTree = ""; }; + 63513DE816A54436003422CA /* UIViewController+BeeExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+BeeExtension.m"; sourceTree = ""; }; + 63513DE916A54436003422CA /* UIViewController+BeeUISignal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+BeeUISignal.h"; sourceTree = ""; }; + 63513DEA16A54436003422CA /* UIViewController+BeeUISignal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+BeeUISignal.m"; sourceTree = ""; }; + 63513DEB16A54436003422CA /* UIViewController+UINavigationBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+UINavigationBar.h"; sourceTree = ""; }; + 63513DEC16A54436003422CA /* UIViewController+UINavigationBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+UINavigationBar.m"; sourceTree = ""; }; + 63513DFB16A54436003422CA /* ASIAuthenticationDialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIAuthenticationDialog.h; sourceTree = ""; }; + 63513DFC16A54436003422CA /* ASIAuthenticationDialog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIAuthenticationDialog.m; sourceTree = ""; }; + 63513DFD16A54436003422CA /* ASICacheDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASICacheDelegate.h; sourceTree = ""; }; + 63513DFE16A54436003422CA /* ASIDataCompressor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIDataCompressor.h; sourceTree = ""; }; + 63513DFF16A54436003422CA /* ASIDataCompressor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIDataCompressor.m; sourceTree = ""; }; + 63513E0016A54436003422CA /* ASIDataDecompressor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIDataDecompressor.h; sourceTree = ""; }; + 63513E0116A54436003422CA /* ASIDataDecompressor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIDataDecompressor.m; sourceTree = ""; }; + 63513E0216A54436003422CA /* ASIDownloadCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIDownloadCache.h; sourceTree = ""; }; + 63513E0316A54436003422CA /* ASIDownloadCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIDownloadCache.m; sourceTree = ""; }; + 63513E0416A54436003422CA /* ASIFormDataRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIFormDataRequest.h; sourceTree = ""; }; + 63513E0516A54436003422CA /* ASIFormDataRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIFormDataRequest.m; sourceTree = ""; }; + 63513E0616A54436003422CA /* ASIHTTPRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIHTTPRequest.h; sourceTree = ""; }; + 63513E0716A54436003422CA /* ASIHTTPRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIHTTPRequest.m; sourceTree = ""; }; + 63513E0816A54436003422CA /* ASIHTTPRequestConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIHTTPRequestConfig.h; sourceTree = ""; }; + 63513E0916A54436003422CA /* ASIHTTPRequestDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIHTTPRequestDelegate.h; sourceTree = ""; }; + 63513E0A16A54436003422CA /* ASIInputStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIInputStream.h; sourceTree = ""; }; + 63513E0B16A54436003422CA /* ASIInputStream.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIInputStream.m; sourceTree = ""; }; + 63513E0C16A54436003422CA /* ASINetworkQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASINetworkQueue.h; sourceTree = ""; }; + 63513E0D16A54436003422CA /* ASINetworkQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASINetworkQueue.m; sourceTree = ""; }; + 63513E0E16A54436003422CA /* ASIProgressDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIProgressDelegate.h; sourceTree = ""; }; + 63513E1016A54436003422CA /* FMDatabase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMDatabase.h; sourceTree = ""; }; + 63513E1116A54436003422CA /* FMDatabase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMDatabase.m; sourceTree = ""; }; + 63513E1216A54436003422CA /* FMDatabaseAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMDatabaseAdditions.h; sourceTree = ""; }; + 63513E1316A54436003422CA /* FMDatabaseAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMDatabaseAdditions.m; sourceTree = ""; }; + 63513E1416A54436003422CA /* FMDatabasePool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMDatabasePool.h; sourceTree = ""; }; + 63513E1516A54436003422CA /* FMDatabasePool.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMDatabasePool.m; sourceTree = ""; }; + 63513E1616A54436003422CA /* FMDatabaseQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMDatabaseQueue.h; sourceTree = ""; }; + 63513E1716A54436003422CA /* FMDatabaseQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMDatabaseQueue.m; sourceTree = ""; }; + 63513E1816A54436003422CA /* FMResultSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMResultSet.h; sourceTree = ""; }; + 63513E1916A54436003422CA /* FMResultSet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMResultSet.m; sourceTree = ""; }; + 63513E1B16A54436003422CA /* JSONKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONKit.h; sourceTree = ""; }; + 63513E1C16A54436003422CA /* JSONKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSONKit.m; sourceTree = ""; }; + 63513E1E16A54436003422CA /* Reachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Reachability.h; sourceTree = ""; }; + 63513E1F16A54436003422CA /* Reachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Reachability.m; sourceTree = ""; }; + 63560A5416AFCA3700F959AA /* Bee_UICameraBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UICameraBoard.h; sourceTree = ""; }; + 63560A5516AFCA3700F959AA /* Bee_UICameraBoard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UICameraBoard.m; sourceTree = ""; }; + 63560A5616AFCA3700F959AA /* Bee_UIFlowBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIFlowBoard.h; sourceTree = ""; }; + 63560A5716AFCA3700F959AA /* Bee_UIFlowBoard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIFlowBoard.m; sourceTree = ""; }; + 63560A5816AFCA3700F959AA /* Bee_UITableBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UITableBoard.h; sourceTree = ""; }; + 63560A5916AFCA3700F959AA /* Bee_UITableBoard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UITableBoard.m; sourceTree = ""; }; + 63560A5A16AFCA3700F959AA /* Bee_UIWebBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIWebBoard.h; sourceTree = ""; }; + 63560A5B16AFCA3700F959AA /* Bee_UIWebBoard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIWebBoard.m; sourceTree = ""; }; 6392685F164CEF600099625C /* CatelogBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CatelogBoard.h; sourceTree = ""; }; 63926860164CEF600099625C /* CatelogBoard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CatelogBoard.m; sourceTree = ""; }; 63926861164CEF600099625C /* DribbbleBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DribbbleBoard.h; sourceTree = ""; }; @@ -237,191 +450,59 @@ 6392688C164CEF600099625C /* Lession9Controller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Lession9Controller.m; sourceTree = ""; }; 6392688D164CEF600099625C /* LessionBaseBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LessionBaseBoard.h; sourceTree = ""; }; 6392688E164CEF600099625C /* LessionBaseBoard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LessionBaseBoard.m; sourceTree = ""; }; - 639268A9164CF7460099625C /* Bee_UIActionSheet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIActionSheet.h; sourceTree = ""; }; - 639268AA164CF7460099625C /* Bee_UIActionSheet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIActionSheet.m; sourceTree = ""; }; - 639268AB164CF7460099625C /* Bee_UIActivityIndicatorView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIActivityIndicatorView.h; sourceTree = ""; }; - 639268AC164CF7460099625C /* Bee_UIActivityIndicatorView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIActivityIndicatorView.m; sourceTree = ""; }; - 639268AD164CF7460099625C /* Bee_UIAlertView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIAlertView.h; sourceTree = ""; }; - 639268AE164CF7460099625C /* Bee_UIAlertView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIAlertView.m; sourceTree = ""; }; - 639268AF164CF7460099625C /* Bee_UIButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIButton.h; sourceTree = ""; }; - 639268B0164CF7460099625C /* Bee_UIButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIButton.m; sourceTree = ""; }; - 639268B3164CF7460099625C /* Bee_UIDatePicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIDatePicker.h; sourceTree = ""; }; - 639268B4164CF7460099625C /* Bee_UIDatePicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIDatePicker.m; sourceTree = ""; }; - 639268B7164CF7460099625C /* Bee_UIGridCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIGridCell.h; sourceTree = ""; }; - 639268B8164CF7460099625C /* Bee_UIGridCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIGridCell.m; sourceTree = ""; }; - 639268B9164CF7460099625C /* Bee_UIImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIImageView.h; sourceTree = ""; }; - 639268BA164CF7460099625C /* Bee_UIImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIImageView.m; sourceTree = ""; }; - 639268BB164CF7460099625C /* Bee_UIKeyboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIKeyboard.h; sourceTree = ""; }; - 639268BC164CF7460099625C /* Bee_UIKeyboard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIKeyboard.m; sourceTree = ""; }; - 639268BD164CF7460099625C /* Bee_UILabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UILabel.h; sourceTree = ""; }; - 639268BE164CF7460099625C /* Bee_UILabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UILabel.m; sourceTree = ""; }; - 639268C1164CF7460099625C /* Bee_UIOrientation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIOrientation.h; sourceTree = ""; }; - 639268C2164CF7460099625C /* Bee_UIOrientation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIOrientation.m; sourceTree = ""; }; - 639268C3164CF7460099625C /* Bee_UIPageControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIPageControl.h; sourceTree = ""; }; - 639268C4164CF7460099625C /* Bee_UIPageControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIPageControl.m; sourceTree = ""; }; - 639268C5164CF7460099625C /* Bee_UIProgressView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIProgressView.h; sourceTree = ""; }; - 639268C6164CF7460099625C /* Bee_UIProgressView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIProgressView.m; sourceTree = ""; }; - 639268C7164CF7460099625C /* Bee_UIPullLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIPullLoader.h; sourceTree = ""; }; - 639268C8164CF7460099625C /* Bee_UIPullLoader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIPullLoader.m; sourceTree = ""; }; - 639268CB164CF7460099625C /* Bee_UIScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIScrollView.h; sourceTree = ""; }; - 639268CC164CF7460099625C /* Bee_UIScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIScrollView.m; sourceTree = ""; }; - 639268CD164CF7460099625C /* Bee_UISegmentedControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UISegmentedControl.h; sourceTree = ""; }; - 639268CE164CF7460099625C /* Bee_UISegmentedControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UISegmentedControl.m; sourceTree = ""; }; - 639268CF164CF7460099625C /* Bee_UISignal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UISignal.h; sourceTree = ""; }; - 639268D0164CF7460099625C /* Bee_UISignal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UISignal.m; sourceTree = ""; }; - 639268D1164CF7460099625C /* Bee_UITabBar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UITabBar.h; sourceTree = ""; }; - 639268D2164CF7460099625C /* Bee_UITabBar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UITabBar.m; sourceTree = ""; }; - 639268D3164CF7460099625C /* Bee_UITextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UITextField.h; sourceTree = ""; }; - 639268D4164CF7460099625C /* Bee_UITextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UITextField.m; sourceTree = ""; }; - 639268D5164CF7460099625C /* Bee_UITextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UITextView.h; sourceTree = ""; }; - 639268D6164CF7460099625C /* Bee_UITextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UITextView.m; sourceTree = ""; }; - 639268D9164CF7460099625C /* Bee_UIWebView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIWebView.h; sourceTree = ""; }; - 639268DA164CF7460099625C /* Bee_UIWebView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIWebView.m; sourceTree = ""; }; - 639268DB164CF7460099625C /* Bee_UIZoomView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIZoomView.h; sourceTree = ""; }; - 639268DC164CF7460099625C /* Bee_UIZoomView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIZoomView.m; sourceTree = ""; }; - 639268DF164CF7460099625C /* UIView+BeeQuery.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+BeeQuery.h"; sourceTree = ""; }; - 639268E0164CF7460099625C /* UIView+BeeQuery.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+BeeQuery.m"; sourceTree = ""; }; - 639268E1164CF7460099625C /* UIView+BeeWireframe.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+BeeWireframe.h"; sourceTree = ""; }; - 639268E2164CF7460099625C /* UIView+BeeWireframe.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+BeeWireframe.m"; sourceTree = ""; }; - 63926900164CFABB0099625C /* UIColor+BeeExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+BeeExtension.h"; sourceTree = ""; }; - 63926901164CFABC0099625C /* UIColor+BeeExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+BeeExtension.m"; sourceTree = ""; }; - 63926903164CFB460099625C /* UIFont+BeeExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIFont+BeeExtension.h"; sourceTree = ""; }; - 63926904164CFB460099625C /* UIFont+BeeExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIFont+BeeExtension.m"; sourceTree = ""; }; - 63926909164CFE4F0099625C /* CGRect+BeeExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CGRect+BeeExtension.h"; sourceTree = ""; }; - 6392690A164CFE500099625C /* CGRect+BeeExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "CGRect+BeeExtension.m"; sourceTree = ""; }; - 6392690C164CFFBC0099625C /* UIImage+BeeExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+BeeExtension.h"; sourceTree = ""; }; - 6392690D164CFFBD0099625C /* UIImage+BeeExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+BeeExtension.m"; sourceTree = ""; }; - 6392690F164D1F4E0099625C /* UIView+BeeBackground.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+BeeBackground.h"; sourceTree = ""; }; - 63926910164D1F520099625C /* UIView+BeeBackground.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+BeeBackground.m"; sourceTree = ""; }; 63926912164D2C220099625C /* Lession10Board.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Lession10Board.h; sourceTree = ""; }; 63926913164D2C250099625C /* Lession10Model.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Lession10Model.h; sourceTree = ""; }; - 63926914164D49D50099625C /* NSDate+BeeExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+BeeExtension.h"; sourceTree = ""; }; - 63926915164D49D90099625C /* NSDate+BeeExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDate+BeeExtension.m"; sourceTree = ""; }; - 6392691A164F88D50099625C /* Bee_DebugHeatmapModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugHeatmapModel.h; sourceTree = ""; }; - 6392691B164F88D50099625C /* Bee_DebugHeatmapModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugHeatmapModel.m; sourceTree = ""; }; - 6392692A164F99320099625C /* tap@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tap@2x.png"; sourceTree = ""; }; - 6392692C164F9CEF0099625C /* heat@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "heat@2x.png"; sourceTree = ""; }; - 63A6314716664044006FC6A0 /* Bee_Precompile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Precompile.h; sourceTree = ""; }; - 63A6314C16665155006FC6A0 /* Contributors.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Contributors.txt; sourceTree = ""; }; - 63A6314D16665163006FC6A0 /* License.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = License.txt; sourceTree = ""; }; - 63A6315216665311006FC6A0 /* FMDatabase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMDatabase.h; sourceTree = ""; }; - 63A6315316665311006FC6A0 /* FMDatabase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMDatabase.m; sourceTree = ""; }; - 63A6315416665311006FC6A0 /* FMDatabaseAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMDatabaseAdditions.h; sourceTree = ""; }; - 63A6315516665311006FC6A0 /* FMDatabaseAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMDatabaseAdditions.m; sourceTree = ""; }; - 63A6315616665311006FC6A0 /* FMDatabasePool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMDatabasePool.h; sourceTree = ""; }; - 63A6315716665311006FC6A0 /* FMDatabasePool.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMDatabasePool.m; sourceTree = ""; }; - 63A6315816665311006FC6A0 /* FMDatabaseQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMDatabaseQueue.h; sourceTree = ""; }; - 63A6315916665311006FC6A0 /* FMDatabaseQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMDatabaseQueue.m; sourceTree = ""; }; - 63A6315B16665311006FC6A0 /* FMResultSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FMResultSet.h; sourceTree = ""; }; - 63A6315C16665311006FC6A0 /* FMResultSet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FMResultSet.m; sourceTree = ""; }; - 63A63163166657D6006FC6A0 /* Bee_Database.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Database.h; sourceTree = ""; }; - 63A63164166657D6006FC6A0 /* Bee_Database.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_Database.m; sourceTree = ""; }; - 63A63166166657EE006FC6A0 /* Bee_ActiveRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_ActiveRecord.h; sourceTree = ""; }; - 63A63167166657EE006FC6A0 /* Bee_ActiveRecord.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_ActiveRecord.m; sourceTree = ""; }; 63A63169166659B2006FC6A0 /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = usr/lib/libsqlite3.dylib; sourceTree = SDKROOT; }; 63A7924B157506E700C863F3 /* WhatsBug.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = WhatsBug.app; sourceTree = BUILT_PRODUCTS_DIR; }; 63A7924F157506E700C863F3 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 63A79251157506E700C863F3 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - 63AFC78515DB522100100B4F /* Bee_DebugViewBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugViewBoard.h; sourceTree = ""; }; - 63AFC78615DB522100100B4F /* Bee_DebugViewBoard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugViewBoard.m; sourceTree = ""; }; - 63AFC79B15DE3EA500100B4F /* Bee_DebugMemoryModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugMemoryModel.h; sourceTree = ""; }; - 63AFC79C15DE3EA500100B4F /* Bee_DebugMemoryModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugMemoryModel.m; sourceTree = ""; }; - 63AFC79E15DE410200100B4F /* Bee_DebugMessageModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugMessageModel.h; sourceTree = ""; }; - 63AFC79F15DE410200100B4F /* Bee_DebugMessageModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugMessageModel.m; sourceTree = ""; }; - 63AFC7A115DE457300100B4F /* Bee_DebugNetworkModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugNetworkModel.h; sourceTree = ""; }; - 63AFC7A215DE457400100B4F /* Bee_DebugNetworkModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugNetworkModel.m; sourceTree = ""; }; - 63AFC7A415DE475C00100B4F /* Bee_DebugDashBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugDashBoard.h; sourceTree = ""; }; - 63AFC7A515DE475D00100B4F /* Bee_DebugDashBoard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugDashBoard.m; sourceTree = ""; }; - 63BF231216535D7F00F4F97C /* ASIAuthenticationDialog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIAuthenticationDialog.h; sourceTree = ""; }; - 63BF231316535D7F00F4F97C /* ASIAuthenticationDialog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIAuthenticationDialog.m; sourceTree = ""; }; - 63BF231416535D7F00F4F97C /* ASICacheDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASICacheDelegate.h; sourceTree = ""; }; - 63BF231516535D7F00F4F97C /* ASIDataCompressor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIDataCompressor.h; sourceTree = ""; }; - 63BF231616535D7F00F4F97C /* ASIDataCompressor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIDataCompressor.m; sourceTree = ""; }; - 63BF231716535D7F00F4F97C /* ASIDataDecompressor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIDataDecompressor.h; sourceTree = ""; }; - 63BF231816535D7F00F4F97C /* ASIDataDecompressor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIDataDecompressor.m; sourceTree = ""; }; - 63BF231916535D7F00F4F97C /* ASIDownloadCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIDownloadCache.h; sourceTree = ""; }; - 63BF231A16535D7F00F4F97C /* ASIDownloadCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIDownloadCache.m; sourceTree = ""; }; - 63BF231B16535D7F00F4F97C /* ASIFormDataRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIFormDataRequest.h; sourceTree = ""; }; - 63BF231C16535D7F00F4F97C /* ASIFormDataRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIFormDataRequest.m; sourceTree = ""; }; - 63BF231D16535D7F00F4F97C /* ASIHTTPRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIHTTPRequest.h; sourceTree = ""; }; - 63BF231E16535D7F00F4F97C /* ASIHTTPRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIHTTPRequest.m; sourceTree = ""; }; - 63BF231F16535D7F00F4F97C /* ASIHTTPRequestConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIHTTPRequestConfig.h; sourceTree = ""; }; - 63BF232016535D7F00F4F97C /* ASIHTTPRequestDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIHTTPRequestDelegate.h; sourceTree = ""; }; - 63BF232116535D7F00F4F97C /* ASIInputStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIInputStream.h; sourceTree = ""; }; - 63BF232216535D7F00F4F97C /* ASIInputStream.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASIInputStream.m; sourceTree = ""; }; - 63BF232316535D7F00F4F97C /* ASINetworkQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASINetworkQueue.h; sourceTree = ""; }; - 63BF232416535D7F00F4F97C /* ASINetworkQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASINetworkQueue.m; sourceTree = ""; }; - 63BF232516535D7F00F4F97C /* ASIProgressDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIProgressDelegate.h; sourceTree = ""; }; - 63BF232716535D7F00F4F97C /* JSONKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSONKit.h; sourceTree = ""; }; - 63BF232816535D7F00F4F97C /* JSONKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSONKit.m; sourceTree = ""; }; - 63BF232A16535D7F00F4F97C /* Reachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Reachability.h; sourceTree = ""; }; - 63BF232B16535D7F00F4F97C /* Reachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Reachability.m; sourceTree = ""; }; - 63BF2345165360FF00F4F97C /* Bee_Keychain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Keychain.h; sourceTree = ""; }; - 63BF2346165360FF00F4F97C /* Bee_Keychain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_Keychain.m; sourceTree = ""; }; - 63C3ABD915F7942600F411F5 /* Bee.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee.h; sourceTree = ""; }; - 63C3ABFA15F7942600F411F5 /* Bee_Cache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Cache.h; sourceTree = ""; }; - 63C3ABFB15F7942600F411F5 /* Bee_Cache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_Cache.m; sourceTree = ""; }; - 63C3ABFC15F7942600F411F5 /* Bee_Log.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Log.h; sourceTree = ""; }; - 63C3ABFD15F7942600F411F5 /* Bee_Log.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Bee_Log.mm; sourceTree = ""; }; - 63C3ABFE15F7942600F411F5 /* Bee_Network.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Network.h; sourceTree = ""; }; - 63C3ABFF15F7942600F411F5 /* Bee_Network.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_Network.m; sourceTree = ""; }; - 63C3AC0015F7942600F411F5 /* Bee_Performance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Performance.h; sourceTree = ""; }; - 63C3AC0115F7942600F411F5 /* Bee_Performance.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Bee_Performance.mm; sourceTree = ""; }; - 63C3AC0215F7942600F411F5 /* Bee_Runtime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Runtime.h; sourceTree = ""; }; - 63C3AC0315F7942600F411F5 /* Bee_Runtime.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Bee_Runtime.mm; sourceTree = ""; }; - 63C3AC0415F7942600F411F5 /* Bee_Sandbox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Sandbox.h; sourceTree = ""; }; - 63C3AC0515F7942600F411F5 /* Bee_Sandbox.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Bee_Sandbox.mm; sourceTree = ""; }; - 63C3AC0615F7942600F411F5 /* Bee_Singleton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Singleton.h; sourceTree = ""; }; - 63C3AC0715F7942600F411F5 /* Bee_Singleton.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Bee_Singleton.mm; sourceTree = ""; }; - 63C3AC0815F7942600F411F5 /* Bee_SystemInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_SystemInfo.h; sourceTree = ""; }; - 63C3AC0915F7942600F411F5 /* Bee_SystemInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_SystemInfo.m; sourceTree = ""; }; - 63C3AC0A15F7942600F411F5 /* Bee_Thread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Thread.h; sourceTree = ""; }; - 63C3AC0B15F7942600F411F5 /* Bee_Thread.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Bee_Thread.mm; sourceTree = ""; }; - 63C3AC0C15F7942600F411F5 /* NSArray+BeeExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+BeeExtension.h"; sourceTree = ""; }; - 63C3AC0D15F7942600F411F5 /* NSArray+BeeExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+BeeExtension.m"; sourceTree = ""; }; - 63C3AC0E15F7942600F411F5 /* NSData+BeeExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+BeeExtension.h"; sourceTree = ""; }; - 63C3AC0F15F7942600F411F5 /* NSData+BeeExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+BeeExtension.m"; sourceTree = ""; }; - 63C3AC1015F7942600F411F5 /* NSDictionary+BeeExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+BeeExtension.h"; sourceTree = ""; }; - 63C3AC1115F7942600F411F5 /* NSDictionary+BeeExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+BeeExtension.m"; sourceTree = ""; }; - 63C3AC1215F7942600F411F5 /* NSNumber+BeeExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSNumber+BeeExtension.h"; sourceTree = ""; }; - 63C3AC1315F7942600F411F5 /* NSNumber+BeeExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSNumber+BeeExtension.m"; sourceTree = ""; }; - 63C3AC1415F7942600F411F5 /* NSObject+BeeNotification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+BeeNotification.h"; sourceTree = ""; }; - 63C3AC1515F7942600F411F5 /* NSObject+BeeNotification.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+BeeNotification.m"; sourceTree = ""; }; - 63C3AC1615F7942600F411F5 /* NSObject+BeeProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+BeeProperty.h"; sourceTree = ""; }; - 63C3AC1715F7942600F411F5 /* NSObject+BeeProperty.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+BeeProperty.m"; sourceTree = ""; }; - 63C3AC1815F7942600F411F5 /* NSObject+BeeTicker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+BeeTicker.h"; sourceTree = ""; }; - 63C3AC1915F7942600F411F5 /* NSObject+BeeTicker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+BeeTicker.m"; sourceTree = ""; }; - 63C3AC1A15F7942600F411F5 /* NSString+BeeExtension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+BeeExtension.h"; sourceTree = ""; }; - 63C3AC1B15F7942600F411F5 /* NSString+BeeExtension.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+BeeExtension.m"; sourceTree = ""; }; - 63C3AC1D15F7942600F411F5 /* Bee_Controller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Controller.h; sourceTree = ""; }; - 63C3AC1E15F7942600F411F5 /* Bee_Controller.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Bee_Controller.mm; sourceTree = ""; }; - 63C3AC1F15F7942600F411F5 /* Bee_Model.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Model.h; sourceTree = ""; }; - 63C3AC2015F7942600F411F5 /* Bee_Model.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_Model.m; sourceTree = ""; }; - 63C3AC2115F7942600F411F5 /* Bee_View.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_View.h; sourceTree = ""; }; - 63C3AC2215F7942600F411F5 /* Bee_View.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_View.m; sourceTree = ""; }; - 63C3AC5115F7942600F411F5 /* Bee_UIBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIBoard.h; sourceTree = ""; }; - 63C3AC5215F7942600F411F5 /* Bee_UIBoard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIBoard.m; sourceTree = ""; }; - 63C3AC5315F7942600F411F5 /* Bee_UIFlowBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIFlowBoard.h; sourceTree = ""; }; - 63C3AC5415F7942600F411F5 /* Bee_UIFlowtBoard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIFlowtBoard.m; sourceTree = ""; }; - 63C3AC5515F7942600F411F5 /* Bee_UIStack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIStack.h; sourceTree = ""; }; - 63C3AC5615F7942600F411F5 /* Bee_UIStack.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIStack.m; sourceTree = ""; }; - 63C3AC5715F7942600F411F5 /* Bee_UIStackGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIStackGroup.h; sourceTree = ""; }; - 63C3AC5815F7942600F411F5 /* Bee_UIStackGroup.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIStackGroup.m; sourceTree = ""; }; - 63C3AC5915F7942600F411F5 /* Bee_UITableBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UITableBoard.h; sourceTree = ""; }; - 63C3AC5A15F7942600F411F5 /* Bee_UITableBoard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UITableBoard.m; sourceTree = ""; }; - 63C3AC5B15F7942600F411F5 /* Bee_UIWebBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UIWebBoard.h; sourceTree = ""; }; - 63C3AC5C15F7942600F411F5 /* Bee_UIWebBoard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UIWebBoard.m; sourceTree = ""; }; - 63D5116116593A37005948E3 /* Bee_DebugViewModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugViewModel.h; sourceTree = ""; }; - 63D5116216593A38005948E3 /* Bee_DebugViewModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugViewModel.m; sourceTree = ""; }; - 63D5116716596493005948E3 /* Bee_DebugCrashReporter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugCrashReporter.h; sourceTree = ""; }; - 63D5116816596494005948E3 /* Bee_DebugCrashReporter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Bee_DebugCrashReporter.mm; sourceTree = ""; }; + 63B46E6316A6BC180087C88C /* Bee_Debug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_Debug.h; sourceTree = ""; }; + 63B46E6416A6BC180087C88C /* Bee_Debug.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_Debug.m; sourceTree = ""; }; + 63B46E6516A6BC180087C88C /* Bee_DebugCrashReporter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugCrashReporter.h; sourceTree = ""; }; + 63B46E6616A6BC180087C88C /* Bee_DebugCrashReporter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Bee_DebugCrashReporter.mm; sourceTree = ""; }; + 63B46E6716A6BC180087C88C /* Bee_DebugDashBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugDashBoard.h; sourceTree = ""; }; + 63B46E6816A6BC180087C88C /* Bee_DebugDashBoard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugDashBoard.m; sourceTree = ""; }; + 63B46E6916A6BC180087C88C /* Bee_DebugDetailView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugDetailView.h; sourceTree = ""; }; + 63B46E6A16A6BC180087C88C /* Bee_DebugDetailView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugDetailView.m; sourceTree = ""; }; + 63B46E6B16A6BC180087C88C /* Bee_DebugHeatmapModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugHeatmapModel.h; sourceTree = ""; }; + 63B46E6C16A6BC180087C88C /* Bee_DebugHeatmapModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugHeatmapModel.m; sourceTree = ""; }; + 63B46E6D16A6BC180087C88C /* Bee_DebugMemoryModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugMemoryModel.h; sourceTree = ""; }; + 63B46E6E16A6BC180087C88C /* Bee_DebugMemoryModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugMemoryModel.m; sourceTree = ""; }; + 63B46E6F16A6BC180087C88C /* Bee_DebugMessageBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugMessageBoard.h; sourceTree = ""; }; + 63B46E7016A6BC180087C88C /* Bee_DebugMessageBoard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugMessageBoard.m; sourceTree = ""; }; + 63B46E7116A6BC180087C88C /* Bee_DebugMessageModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugMessageModel.h; sourceTree = ""; }; + 63B46E7216A6BC180087C88C /* Bee_DebugMessageModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugMessageModel.m; sourceTree = ""; }; + 63B46E7316A6BC180087C88C /* Bee_DebugNetworkBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugNetworkBoard.h; sourceTree = ""; }; + 63B46E7416A6BC180087C88C /* Bee_DebugNetworkBoard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugNetworkBoard.m; sourceTree = ""; }; + 63B46E7516A6BC180087C88C /* Bee_DebugNetworkModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugNetworkModel.h; sourceTree = ""; }; + 63B46E7616A6BC180087C88C /* Bee_DebugNetworkModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugNetworkModel.m; sourceTree = ""; }; + 63B46E7716A6BC180087C88C /* Bee_DebugPieView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugPieView.h; sourceTree = ""; }; + 63B46E7816A6BC180087C88C /* Bee_DebugPieView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugPieView.m; sourceTree = ""; }; + 63B46E7916A6BC180087C88C /* Bee_DebugPlotsView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugPlotsView.h; sourceTree = ""; }; + 63B46E7A16A6BC180087C88C /* Bee_DebugPlotsView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugPlotsView.m; sourceTree = ""; }; + 63B46E7B16A6BC180087C88C /* Bee_DebugSampleView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugSampleView.h; sourceTree = ""; }; + 63B46E7C16A6BC180087C88C /* Bee_DebugSampleView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugSampleView.m; sourceTree = ""; }; + 63B46E7D16A6BC180087C88C /* Bee_DebugSandboxBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugSandboxBoard.h; sourceTree = ""; }; + 63B46E7E16A6BC180087C88C /* Bee_DebugSandboxBoard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugSandboxBoard.m; sourceTree = ""; }; + 63B46E7F16A6BC180087C88C /* Bee_DebugUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugUtility.h; sourceTree = ""; }; + 63B46E8016A6BC180087C88C /* Bee_DebugUtility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugUtility.m; sourceTree = ""; }; + 63B46E8116A6BC180087C88C /* Bee_DebugViewBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugViewBoard.h; sourceTree = ""; }; + 63B46E8216A6BC180087C88C /* Bee_DebugViewBoard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugViewBoard.m; sourceTree = ""; }; + 63B46E8316A6BC180087C88C /* Bee_DebugViewModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugViewModel.h; sourceTree = ""; }; + 63B46E8416A6BC180087C88C /* Bee_DebugViewModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugViewModel.m; sourceTree = ""; }; + 63B46E8516A6BC180087C88C /* Bee_DebugWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_DebugWindow.h; sourceTree = ""; }; + 63B46E8616A6BC180087C88C /* Bee_DebugWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_DebugWindow.m; sourceTree = ""; }; + 63B46E8716A6BC180087C88C /* bug@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "bug@2x.png"; sourceTree = ""; }; + 63B46E8816A6BC180087C88C /* close@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "close@2x.png"; sourceTree = ""; }; + 63B46E8916A6BC180087C88C /* file@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "file@2x.png"; sourceTree = ""; }; + 63B46E8A16A6BC180087C88C /* folder@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "folder@2x.png"; sourceTree = ""; }; + 63B46E8B16A6BC180087C88C /* heat@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "heat@2x.png"; sourceTree = ""; }; + 63B46E8C16A6BC180087C88C /* tap@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tap@2x.png"; sourceTree = ""; }; 63EAE481166E2C5500C6F40E /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 63F5FB6B166CE38A00139103 /* Lession11Board.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Lession11Board.h; sourceTree = ""; }; 63F5FB6C166CE38B00139103 /* Lession11Board.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Lession11Board.m; sourceTree = ""; }; 63F5FB71166CE53800139103 /* Lession11Model.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Lession11Model.h; sourceTree = ""; }; 63F5FB72166CE53900139103 /* Lession11Model.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Lession11Model.m; sourceTree = ""; }; - 63F8E90D160C595300A5FECC /* Bee_UICameraBoard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Bee_UICameraBoard.h; sourceTree = ""; }; - 63F8E90E160C595300A5FECC /* Bee_UICameraBoard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Bee_UICameraBoard.m; sourceTree = ""; }; 63F8E910160C599B00A5FECC /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; 63F8E915160C5B6A00A5FECC /* CoreVideo.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreVideo.framework; path = System/Library/Frameworks/CoreVideo.framework; sourceTree = SDKROOT; }; 63F8E917160C5B8900A5FECC /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; }; @@ -462,54 +543,431 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 63133C5915D4E5F0009A5BFC /* BeeDebugger */ = { + 63513D2E16A54436003422CA /* BeeFramework */ = { isa = PBXGroup; children = ( - 63133C5A15D4E5F0009A5BFC /* Bee_Debug.h */, - 63133C5B15D4E5F0009A5BFC /* Bee_Debug.m */, - 63D5116716596493005948E3 /* Bee_DebugCrashReporter.h */, - 63D5116816596494005948E3 /* Bee_DebugCrashReporter.mm */, - 63AFC7A415DE475C00100B4F /* Bee_DebugDashBoard.h */, - 63AFC7A515DE475D00100B4F /* Bee_DebugDashBoard.m */, - 6392691A164F88D50099625C /* Bee_DebugHeatmapModel.h */, - 6392691B164F88D50099625C /* Bee_DebugHeatmapModel.m */, - 63AFC79B15DE3EA500100B4F /* Bee_DebugMemoryModel.h */, - 63AFC79C15DE3EA500100B4F /* Bee_DebugMemoryModel.m */, - 63AFC79E15DE410200100B4F /* Bee_DebugMessageModel.h */, - 63AFC79F15DE410200100B4F /* Bee_DebugMessageModel.m */, - 63133C6615D4E5F0009A5BFC /* Bee_DebugMessageBoard.h */, - 63133C6715D4E5F0009A5BFC /* Bee_DebugMessageBoard.m */, - 63AFC7A115DE457300100B4F /* Bee_DebugNetworkModel.h */, - 63AFC7A215DE457400100B4F /* Bee_DebugNetworkModel.m */, - 63133C9B15D8BF18009A5BFC /* Bee_DebugNetworkBoard.h */, - 63133C9C15D8BF1A009A5BFC /* Bee_DebugNetworkBoard.m */, - 63133C6815D4E5F0009A5BFC /* Bee_DebugDetailView.h */, - 63133C6915D4E5F0009A5BFC /* Bee_DebugDetailView.m */, - 63133C6A15D4E5F0009A5BFC /* Bee_DebugPieView.h */, - 63133C6B15D4E5F0009A5BFC /* Bee_DebugPieView.m */, - 63133C6C15D4E5F0009A5BFC /* Bee_DebugPlotsView.h */, - 63133C6D15D4E5F0009A5BFC /* Bee_DebugPlotsView.m */, - 63133C6E15D4E5F0009A5BFC /* Bee_DebugSampleView.h */, - 63133C6F15D4E5F0009A5BFC /* Bee_DebugSampleView.m */, - 63133C8F15D8A7A2009A5BFC /* Bee_DebugSandboxBoard.h */, - 63133C9015D8A7A2009A5BFC /* Bee_DebugSandboxBoard.m */, - 63133C9215D8B39A009A5BFC /* Bee_DebugUtility.h */, - 63133C9315D8B39B009A5BFC /* Bee_DebugUtility.m */, - 63AFC78515DB522100100B4F /* Bee_DebugViewBoard.h */, - 63AFC78615DB522100100B4F /* Bee_DebugViewBoard.m */, - 63D5116116593A37005948E3 /* Bee_DebugViewModel.h */, - 63D5116216593A38005948E3 /* Bee_DebugViewModel.m */, - 63133C7215D4E5F0009A5BFC /* Bee_DebugWindow.h */, - 63133C7315D4E5F0009A5BFC /* Bee_DebugWindow.m */, - 63133C7415D4E5F0009A5BFC /* bug@2x.png */, - 63133C7515D4E5F0009A5BFC /* close@2x.png */, - 63133C7615D4E5F0009A5BFC /* file@2x.png */, - 63133C7715D4E5F0009A5BFC /* folder@2x.png */, - 6392692A164F99320099625C /* tap@2x.png */, - 6392692C164F9CEF0099625C /* heat@2x.png */, + 63513D2F16A54436003422CA /* Bee.h */, + 63513D3016A54436003422CA /* Bee_Precompile.h */, + 63513D3116A54436003422CA /* Core */, + 63513D7F16A54436003422CA /* MVC */, ); - name = BeeDebugger; - path = ../BeeDebugger; + name = BeeFramework; + path = ../BeeFramework; + sourceTree = ""; + }; + 63513D3116A54436003422CA /* Core */ = { + isa = PBXGroup; + children = ( + 63513D3216A54436003422CA /* Bee_Core.h */, + 63513D3316A54436003422CA /* Foundation */, + 63513D5916A54436003422CA /* Network */, + 63513D6316A54436003422CA /* Storage */, + 63513D7A16A54436003422CA /* UnitTest */, + ); + path = Core; + sourceTree = ""; + }; + 63513D3316A54436003422CA /* Foundation */ = { + isa = PBXGroup; + children = ( + 63513D3416A54436003422CA /* Bee_Foundation.h */, + 63513D3516A54436003422CA /* Bee_Foundation.mm */, + 63513D3616A54436003422CA /* Bee_Log.h */, + 63513D3716A54436003422CA /* Bee_Log.mm */, + 63513D3816A54436003422CA /* Bee_Performance.h */, + 63513D3916A54436003422CA /* Bee_Performance.mm */, + 63513D3A16A54436003422CA /* Bee_Runtime.h */, + 63513D3B16A54436003422CA /* Bee_Runtime.mm */, + 63513D3C16A54436003422CA /* Bee_Sandbox.h */, + 63513D3D16A54436003422CA /* Bee_Sandbox.mm */, + 63513D3E16A54436003422CA /* Bee_Singleton.h */, + 63513D3F16A54436003422CA /* Bee_Singleton.mm */, + 63513D4016A54436003422CA /* Bee_SystemInfo.h */, + 63513D4116A54436003422CA /* Bee_SystemInfo.m */, + 63513D4216A54436003422CA /* Bee_Thread.h */, + 63513D4316A54436003422CA /* Bee_Thread.mm */, + 63513D4416A54436003422CA /* Extension */, + ); + path = Foundation; + sourceTree = ""; + }; + 63513D4416A54436003422CA /* Extension */ = { + isa = PBXGroup; + children = ( + 63513D4516A54436003422CA /* NSArray+BeeExtension.h */, + 63513D4616A54436003422CA /* NSArray+BeeExtension.m */, + 63513D4716A54436003422CA /* NSData+BeeExtension.h */, + 63513D4816A54436003422CA /* NSData+BeeExtension.m */, + 63513D4916A54436003422CA /* NSDate+BeeExtension.h */, + 63513D4A16A54436003422CA /* NSDate+BeeExtension.m */, + 63513D4B16A54436003422CA /* NSDictionary+BeeExtension.h */, + 63513D4C16A54436003422CA /* NSDictionary+BeeExtension.m */, + 63513D4D16A54436003422CA /* NSNumber+BeeExtension.h */, + 63513D4E16A54436003422CA /* NSNumber+BeeExtension.m */, + 63513D4F16A54436003422CA /* NSObject+BeeNotification.h */, + 63513D5016A54436003422CA /* NSObject+BeeNotification.m */, + 63513D5116A54436003422CA /* NSObject+BeeProperty.h */, + 63513D5216A54436003422CA /* NSObject+BeeProperty.m */, + 63513D5316A54436003422CA /* NSObject+BeeTicker.h */, + 63513D5416A54436003422CA /* NSObject+BeeTicker.m */, + 63513D5516A54436003422CA /* NSObject+BeeTypeConversion.h */, + 63513D5616A54436003422CA /* NSObject+BeeTypeConversion.m */, + 63513D5716A54436003422CA /* NSString+BeeExtension.h */, + 63513D5816A54436003422CA /* NSString+BeeExtension.m */, + ); + path = Extension; + sourceTree = ""; + }; + 63513D5916A54436003422CA /* Network */ = { + isa = PBXGroup; + children = ( + 63513D5A16A54436003422CA /* Bee_Network.h */, + 63513D5B16A54436003422CA /* Bee_Network.m */, + 63513D5C16A54436003422CA /* Bee_Request.h */, + 63513D5D16A54436003422CA /* Bee_Request.m */, + 63513D5E16A54436003422CA /* Bee_RequestQueue.h */, + 63513D5F16A54436003422CA /* Bee_RequestQueue.m */, + 63513D6016A54436003422CA /* Extension */, + ); + path = Network; + sourceTree = ""; + }; + 63513D6016A54436003422CA /* Extension */ = { + isa = PBXGroup; + children = ( + 63513D6116A54436003422CA /* NSObject+BeeRequest.h */, + 63513D6216A54436003422CA /* NSObject+BeeRequest.m */, + ); + path = Extension; + sourceTree = ""; + }; + 63513D6316A54436003422CA /* Storage */ = { + isa = PBXGroup; + children = ( + 63513D6416A54436003422CA /* Bee_ActiveBase.h */, + 63513D6516A54436003422CA /* Bee_ActiveBase.m */, + 63513D6616A54436003422CA /* Bee_ActiveBaseTest.m */, + 63513D6716A54436003422CA /* Bee_ActiveRecord.h */, + 63513D6816A54436003422CA /* Bee_ActiveRecord.m */, + 63513D6916A54436003422CA /* Bee_ActiveRecordTest.m */, + 63513D6A16A54436003422CA /* Bee_Cache.h */, + 63513D6B16A54436003422CA /* Bee_Cache.m */, + 63513D6C16A54436003422CA /* Bee_CacheTest.m */, + 63513D6D16A54436003422CA /* Bee_Database.h */, + 63513D6E16A54436003422CA /* Bee_Database.m */, + 63513D6F16A54436003422CA /* Bee_DatabaseTest.m */, + 63513D7016A54436003422CA /* Bee_Keychain.h */, + 63513D7116A54436003422CA /* Bee_Keychain.m */, + 63513D7216A54436003422CA /* Bee_KeychainTest.m */, + 63513D7316A54436003422CA /* Bee_Storage.h */, + 63513D7416A54436003422CA /* Bee_Storage.m */, + 63513D7516A54436003422CA /* Extension */, + ); + path = Storage; + sourceTree = ""; + }; + 63513D7516A54436003422CA /* Extension */ = { + isa = PBXGroup; + children = ( + 63513D7616A54436003422CA /* NSObject+BeeDatabase.h */, + 63513D7716A54436003422CA /* NSObject+BeeDatabase.m */, + 63513D7816A54436003422CA /* NSObject+BeeKeychain.h */, + 63513D7916A54436003422CA /* NSObject+BeeKeychain.m */, + ); + path = Extension; + sourceTree = ""; + }; + 63513D7A16A54436003422CA /* UnitTest */ = { + isa = PBXGroup; + children = ( + 63513D7B16A54436003422CA /* Bee_UnitTest.h */, + 63513D7C16A54436003422CA /* Bee_UnitTest.m */, + ); + path = UnitTest; + sourceTree = ""; + }; + 63513D7F16A54436003422CA /* MVC */ = { + isa = PBXGroup; + children = ( + 63513D8016A54436003422CA /* Bee_MVC.h */, + 63513D8116A54436003422CA /* Controller */, + 63513D9316A54436003422CA /* Model */, + 63513D9716A54436003422CA /* View */, + 63513DDD16A54436003422CA /* ViewController */, + ); + path = MVC; + sourceTree = ""; + }; + 63513D8116A54436003422CA /* Controller */ = { + isa = PBXGroup; + children = ( + 63513D8216A54436003422CA /* Bee_Controller.h */, + 63513D8316A54436003422CA /* Bee_Controller.mm */, + 63513D8416A54436003422CA /* Bee_Message.h */, + 63513D8516A54436003422CA /* Bee_Message.mm */, + 63513D8616A54436003422CA /* Bee_MessageQueue.h */, + 63513D8716A54436003422CA /* Bee_MessageQueue.mm */, + 63513D8816A54436003422CA /* Extension */, + ); + path = Controller; + sourceTree = ""; + }; + 63513D8816A54436003422CA /* Extension */ = { + isa = PBXGroup; + children = ( + 63513D8916A54436003422CA /* BeeMessage+ActiveRecord.h */, + 63513D8A16A54436003422CA /* BeeMessage+ActiveRecord.m */, + 63513D8B16A54436003422CA /* BeeMessage+HTTP.h */, + 63513D8C16A54436003422CA /* BeeMessage+HTTP.mm */, + 63513D8D16A54436003422CA /* BeeMessage+JSON.h */, + 63513D8E16A54436003422CA /* BeeMessage+JSON.mm */, + 63513D8F16A54436003422CA /* BeeMessage+XML.h */, + 63513D9016A54436003422CA /* BeeMessage+XML.mm */, + 63513D9116A54436003422CA /* NSObject+BeeMessage.h */, + 63513D9216A54436003422CA /* NSObject+BeeMessage.mm */, + ); + path = Extension; + sourceTree = ""; + }; + 63513D9316A54436003422CA /* Model */ = { + isa = PBXGroup; + children = ( + 63513D9416A54436003422CA /* Bee_Model.h */, + 63513D9516A54436003422CA /* Bee_Model.m */, + 63513D9616A54436003422CA /* Extension */, + ); + path = Model; + sourceTree = ""; + }; + 63513D9616A54436003422CA /* Extension */ = { + isa = PBXGroup; + children = ( + ); + path = Extension; + sourceTree = ""; + }; + 63513D9716A54436003422CA /* View */ = { + isa = PBXGroup; + children = ( + 63513D9816A54436003422CA /* Bee_UIActionSheet.h */, + 63513D9916A54436003422CA /* Bee_UIActionSheet.m */, + 63513D9A16A54436003422CA /* Bee_UIActivityIndicatorView.h */, + 63513D9B16A54436003422CA /* Bee_UIActivityIndicatorView.m */, + 63513D9C16A54436003422CA /* Bee_UIAlertView.h */, + 63513D9D16A54436003422CA /* Bee_UIAlertView.m */, + 63513D9E16A54436003422CA /* Bee_UIButton.h */, + 63513D9F16A54436003422CA /* Bee_UIButton.m */, + 63513DA016A54436003422CA /* Bee_UIDatePicker.h */, + 63513DA116A54436003422CA /* Bee_UIDatePicker.m */, + 63513DA216A54436003422CA /* Bee_UIGridCell.h */, + 63513DA316A54436003422CA /* Bee_UIGridCell.m */, + 63513DA416A54436003422CA /* Bee_UIImageView.h */, + 63513DA516A54436003422CA /* Bee_UIImageView.m */, + 63513DA616A54436003422CA /* Bee_UIKeyboard.h */, + 63513DA716A54436003422CA /* Bee_UIKeyboard.m */, + 63513DA816A54436003422CA /* Bee_UILabel.h */, + 63513DA916A54436003422CA /* Bee_UILabel.m */, + 63513DAA16A54436003422CA /* Bee_UIOrientation.h */, + 63513DAB16A54436003422CA /* Bee_UIOrientation.m */, + 63513DAC16A54436003422CA /* Bee_UIPageControl.h */, + 63513DAD16A54436003422CA /* Bee_UIPageControl.m */, + 63513DAE16A54436003422CA /* Bee_UIProgressView.h */, + 63513DAF16A54436003422CA /* Bee_UIProgressView.m */, + 63513DB016A54436003422CA /* Bee_UIPullLoader.h */, + 63513DB116A54436003422CA /* Bee_UIPullLoader.m */, + 63513DB216A54436003422CA /* Bee_UIScrollView.h */, + 63513DB316A54436003422CA /* Bee_UIScrollView.m */, + 63513DB416A54436003422CA /* Bee_UISegmentedControl.h */, + 63513DB516A54436003422CA /* Bee_UISegmentedControl.m */, + 63513DB616A54436003422CA /* Bee_UISignal.h */, + 63513DB716A54436003422CA /* Bee_UISignal.m */, + 63513DB816A54436003422CA /* Bee_UITabBar.h */, + 63513DB916A54436003422CA /* Bee_UITabBar.m */, + 63513DBA16A54436003422CA /* Bee_UITextField.h */, + 63513DBB16A54436003422CA /* Bee_UITextField.m */, + 63513DBC16A54436003422CA /* Bee_UITextView.h */, + 63513DBD16A54436003422CA /* Bee_UITextView.m */, + 63513DBE16A54436003422CA /* Bee_UITipsView.h */, + 63513DBF16A54436003422CA /* Bee_UITipsView.m */, + 63513DC016A54436003422CA /* Bee_UIWebView.h */, + 63513DC116A54436003422CA /* Bee_UIWebView.m */, + 63513DC216A54436003422CA /* Bee_UIZoomView.h */, + 63513DC316A54436003422CA /* Bee_UIZoomView.m */, + 63513DC416A54436003422CA /* Bee_View.h */, + 63513DC516A54436003422CA /* Bee_View.m */, + 63513DC616A54436003422CA /* Extension */, + ); + path = View; + sourceTree = ""; + }; + 63513DC616A54436003422CA /* Extension */ = { + isa = PBXGroup; + children = ( + 63513DC716A54436003422CA /* CGRect+BeeExtension.h */, + 63513DC816A54436003422CA /* CGRect+BeeExtension.m */, + 63513DCB16A54436003422CA /* UIColor+BeeExtension.h */, + 63513DCC16A54436003422CA /* UIColor+BeeExtension.m */, + 63513DCD16A54436003422CA /* UIFont+BeeExtension.h */, + 63513DCE16A54436003422CA /* UIFont+BeeExtension.m */, + 63513DCF16A54436003422CA /* UIImage+BeeExtension.h */, + 63513DD016A54436003422CA /* UIImage+BeeExtension.m */, + 63513DD116A54436003422CA /* UIView+BeeExtension.h */, + 63513DD216A54436003422CA /* UIView+BeeExtension.m */, + 63513DD316A54436003422CA /* UIView+BeeUISignal.h */, + 63513DD416A54436003422CA /* UIView+BeeUISignal.m */, + 63513DD516A54436003422CA /* UIView+HoldGesture.h */, + 63513DD616A54436003422CA /* UIView+HoldGesture.m */, + 63513DD716A54436003422CA /* UIView+PanGesture.h */, + 63513DD816A54436003422CA /* UIView+PanGesture.m */, + 63513DD916A54436003422CA /* UIView+SwipeGesture.h */, + 63513DDA16A54436003422CA /* UIView+SwipeGesture.m */, + 63513DDB16A54436003422CA /* UIView+TapGesture.h */, + 63513DDC16A54436003422CA /* UIView+TapGesture.m */, + ); + path = Extension; + sourceTree = ""; + }; + 63513DDD16A54436003422CA /* ViewController */ = { + isa = PBXGroup; + children = ( + 63513DDE16A54436003422CA /* Bee_UIBoard.h */, + 63513DDF16A54436003422CA /* Bee_UIBoard.m */, + 63513DE016A54436003422CA /* Bee_UIStack.h */, + 63513DE116A54436003422CA /* Bee_UIStack.m */, + 63513DE216A54436003422CA /* Bee_UIStackGroup.h */, + 63513DE316A54436003422CA /* Bee_UIStackGroup.m */, + 63513DE416A54436003422CA /* Bee_ViewController.h */, + 63513DE516A54436003422CA /* Bee_ViewController.m */, + 63513DE616A54436003422CA /* Extension */, + ); + path = ViewController; + sourceTree = ""; + }; + 63513DE616A54436003422CA /* Extension */ = { + isa = PBXGroup; + children = ( + 63513DE716A54436003422CA /* UIViewController+BeeExtension.h */, + 63513DE816A54436003422CA /* UIViewController+BeeExtension.m */, + 63513DE916A54436003422CA /* UIViewController+BeeUISignal.h */, + 63513DEA16A54436003422CA /* UIViewController+BeeUISignal.m */, + 63513DEB16A54436003422CA /* UIViewController+UINavigationBar.h */, + 63513DEC16A54436003422CA /* UIViewController+UINavigationBar.m */, + ); + path = Extension; + sourceTree = ""; + }; + 63513DF016A54436003422CA /* BeeTemplates */ = { + isa = PBXGroup; + children = ( + 63560A5316AFCA3700F959AA /* CustomBoard */, + 63560A5C16AFCA3700F959AA /* CustomView */, + ); + name = BeeTemplates; + path = ../BeeTemplates; + sourceTree = ""; + }; + 63513DF916A54436003422CA /* External */ = { + isa = PBXGroup; + children = ( + 63513DFA16A54436003422CA /* ASI */, + 63513E0F16A54436003422CA /* FMDB */, + 63513E1A16A54436003422CA /* JSONKit */, + 63513E1D16A54436003422CA /* Reachability */, + 63513E2016A54436003422CA /* SFHFKeychainUtils */, + ); + name = External; + path = ../External; + sourceTree = ""; + }; + 63513DFA16A54436003422CA /* ASI */ = { + isa = PBXGroup; + children = ( + 63513DFB16A54436003422CA /* ASIAuthenticationDialog.h */, + 63513DFC16A54436003422CA /* ASIAuthenticationDialog.m */, + 63513DFD16A54436003422CA /* ASICacheDelegate.h */, + 63513DFE16A54436003422CA /* ASIDataCompressor.h */, + 63513DFF16A54436003422CA /* ASIDataCompressor.m */, + 63513E0016A54436003422CA /* ASIDataDecompressor.h */, + 63513E0116A54436003422CA /* ASIDataDecompressor.m */, + 63513E0216A54436003422CA /* ASIDownloadCache.h */, + 63513E0316A54436003422CA /* ASIDownloadCache.m */, + 63513E0416A54436003422CA /* ASIFormDataRequest.h */, + 63513E0516A54436003422CA /* ASIFormDataRequest.m */, + 63513E0616A54436003422CA /* ASIHTTPRequest.h */, + 63513E0716A54436003422CA /* ASIHTTPRequest.m */, + 63513E0816A54436003422CA /* ASIHTTPRequestConfig.h */, + 63513E0916A54436003422CA /* ASIHTTPRequestDelegate.h */, + 63513E0A16A54436003422CA /* ASIInputStream.h */, + 63513E0B16A54436003422CA /* ASIInputStream.m */, + 63513E0C16A54436003422CA /* ASINetworkQueue.h */, + 63513E0D16A54436003422CA /* ASINetworkQueue.m */, + 63513E0E16A54436003422CA /* ASIProgressDelegate.h */, + ); + path = ASI; + sourceTree = ""; + }; + 63513E0F16A54436003422CA /* FMDB */ = { + isa = PBXGroup; + children = ( + 63513E1016A54436003422CA /* FMDatabase.h */, + 63513E1116A54436003422CA /* FMDatabase.m */, + 63513E1216A54436003422CA /* FMDatabaseAdditions.h */, + 63513E1316A54436003422CA /* FMDatabaseAdditions.m */, + 63513E1416A54436003422CA /* FMDatabasePool.h */, + 63513E1516A54436003422CA /* FMDatabasePool.m */, + 63513E1616A54436003422CA /* FMDatabaseQueue.h */, + 63513E1716A54436003422CA /* FMDatabaseQueue.m */, + 63513E1816A54436003422CA /* FMResultSet.h */, + 63513E1916A54436003422CA /* FMResultSet.m */, + ); + path = FMDB; + sourceTree = ""; + }; + 63513E1A16A54436003422CA /* JSONKit */ = { + isa = PBXGroup; + children = ( + 63513E1B16A54436003422CA /* JSONKit.h */, + 63513E1C16A54436003422CA /* JSONKit.m */, + ); + path = JSONKit; + sourceTree = ""; + }; + 63513E1D16A54436003422CA /* Reachability */ = { + isa = PBXGroup; + children = ( + 63513E1E16A54436003422CA /* Reachability.h */, + 63513E1F16A54436003422CA /* Reachability.m */, + ); + path = Reachability; + sourceTree = ""; + }; + 63513E2016A54436003422CA /* SFHFKeychainUtils */ = { + isa = PBXGroup; + children = ( + ); + path = SFHFKeychainUtils; + sourceTree = ""; + }; + 63560A5316AFCA3700F959AA /* CustomBoard */ = { + isa = PBXGroup; + children = ( + 63560A5416AFCA3700F959AA /* Bee_UICameraBoard.h */, + 63560A5516AFCA3700F959AA /* Bee_UICameraBoard.m */, + 63560A5616AFCA3700F959AA /* Bee_UIFlowBoard.h */, + 63560A5716AFCA3700F959AA /* Bee_UIFlowBoard.m */, + 63560A5816AFCA3700F959AA /* Bee_UITableBoard.h */, + 63560A5916AFCA3700F959AA /* Bee_UITableBoard.m */, + 63560A5A16AFCA3700F959AA /* Bee_UIWebBoard.h */, + 63560A5B16AFCA3700F959AA /* Bee_UIWebBoard.m */, + ); + path = CustomBoard; + sourceTree = ""; + }; + 63560A5C16AFCA3700F959AA /* CustomView */ = { + isa = PBXGroup; + children = ( + ); + path = CustomView; sourceTree = ""; }; 6392685E164CEF600099625C /* Lessions */ = { @@ -571,107 +1029,13 @@ path = Lessions; sourceTree = SOURCE_ROOT; }; - 639268A8164CF7460099625C /* View */ = { - isa = PBXGroup; - children = ( - 639268A9164CF7460099625C /* Bee_UIActionSheet.h */, - 639268AA164CF7460099625C /* Bee_UIActionSheet.m */, - 639268AB164CF7460099625C /* Bee_UIActivityIndicatorView.h */, - 639268AC164CF7460099625C /* Bee_UIActivityIndicatorView.m */, - 639268AD164CF7460099625C /* Bee_UIAlertView.h */, - 639268AE164CF7460099625C /* Bee_UIAlertView.m */, - 639268AF164CF7460099625C /* Bee_UIButton.h */, - 639268B0164CF7460099625C /* Bee_UIButton.m */, - 639268B3164CF7460099625C /* Bee_UIDatePicker.h */, - 639268B4164CF7460099625C /* Bee_UIDatePicker.m */, - 639268B7164CF7460099625C /* Bee_UIGridCell.h */, - 639268B8164CF7460099625C /* Bee_UIGridCell.m */, - 639268B9164CF7460099625C /* Bee_UIImageView.h */, - 639268BA164CF7460099625C /* Bee_UIImageView.m */, - 639268BB164CF7460099625C /* Bee_UIKeyboard.h */, - 639268BC164CF7460099625C /* Bee_UIKeyboard.m */, - 639268BD164CF7460099625C /* Bee_UILabel.h */, - 639268BE164CF7460099625C /* Bee_UILabel.m */, - 639268C1164CF7460099625C /* Bee_UIOrientation.h */, - 639268C2164CF7460099625C /* Bee_UIOrientation.m */, - 639268C3164CF7460099625C /* Bee_UIPageControl.h */, - 639268C4164CF7460099625C /* Bee_UIPageControl.m */, - 639268C5164CF7460099625C /* Bee_UIProgressView.h */, - 639268C6164CF7460099625C /* Bee_UIProgressView.m */, - 639268C7164CF7460099625C /* Bee_UIPullLoader.h */, - 639268C8164CF7460099625C /* Bee_UIPullLoader.m */, - 639268CB164CF7460099625C /* Bee_UIScrollView.h */, - 639268CC164CF7460099625C /* Bee_UIScrollView.m */, - 639268CD164CF7460099625C /* Bee_UISegmentedControl.h */, - 639268CE164CF7460099625C /* Bee_UISegmentedControl.m */, - 639268CF164CF7460099625C /* Bee_UISignal.h */, - 639268D0164CF7460099625C /* Bee_UISignal.m */, - 639268D1164CF7460099625C /* Bee_UITabBar.h */, - 639268D2164CF7460099625C /* Bee_UITabBar.m */, - 639268D3164CF7460099625C /* Bee_UITextField.h */, - 639268D4164CF7460099625C /* Bee_UITextField.m */, - 639268D5164CF7460099625C /* Bee_UITextView.h */, - 639268D6164CF7460099625C /* Bee_UITextView.m */, - 639268D9164CF7460099625C /* Bee_UIWebView.h */, - 639268DA164CF7460099625C /* Bee_UIWebView.m */, - 639268DB164CF7460099625C /* Bee_UIZoomView.h */, - 639268DC164CF7460099625C /* Bee_UIZoomView.m */, - 63926909164CFE4F0099625C /* CGRect+BeeExtension.h */, - 6392690A164CFE500099625C /* CGRect+BeeExtension.m */, - 63926900164CFABB0099625C /* UIColor+BeeExtension.h */, - 63926901164CFABC0099625C /* UIColor+BeeExtension.m */, - 63926903164CFB460099625C /* UIFont+BeeExtension.h */, - 63926904164CFB460099625C /* UIFont+BeeExtension.m */, - 6392690C164CFFBC0099625C /* UIImage+BeeExtension.h */, - 6392690D164CFFBD0099625C /* UIImage+BeeExtension.m */, - 6392690F164D1F4E0099625C /* UIView+BeeBackground.h */, - 63926910164D1F520099625C /* UIView+BeeBackground.m */, - 639268DF164CF7460099625C /* UIView+BeeQuery.h */, - 639268E0164CF7460099625C /* UIView+BeeQuery.m */, - 639268E1164CF7460099625C /* UIView+BeeWireframe.h */, - 639268E2164CF7460099625C /* UIView+BeeWireframe.m */, - ); - path = View; - sourceTree = ""; - }; - 63A63150166652BB006FC6A0 /* Storage */ = { - isa = PBXGroup; - children = ( - 63A63166166657EE006FC6A0 /* Bee_ActiveRecord.h */, - 63A63167166657EE006FC6A0 /* Bee_ActiveRecord.m */, - 633F6DFD166B88EA0079B3C9 /* Bee_ActiveRecordTest.h */, - 633F6DFE166B88EA0079B3C9 /* Bee_ActiveRecordTest.m */, - 63A63163166657D6006FC6A0 /* Bee_Database.h */, - 63A63164166657D6006FC6A0 /* Bee_Database.m */, - 633F6DFA166A7D860079B3C9 /* Bee_DatabaseTest.h */, - 633F6DFB166A7D860079B3C9 /* Bee_DatabaseTest.m */, - ); - path = Storage; - sourceTree = ""; - }; - 63A6315116665311006FC6A0 /* FMDB */ = { - isa = PBXGroup; - children = ( - 63A6315216665311006FC6A0 /* FMDatabase.h */, - 63A6315316665311006FC6A0 /* FMDatabase.m */, - 63A6315416665311006FC6A0 /* FMDatabaseAdditions.h */, - 63A6315516665311006FC6A0 /* FMDatabaseAdditions.m */, - 63A6315616665311006FC6A0 /* FMDatabasePool.h */, - 63A6315716665311006FC6A0 /* FMDatabasePool.m */, - 63A6315816665311006FC6A0 /* FMDatabaseQueue.h */, - 63A6315916665311006FC6A0 /* FMDatabaseQueue.m */, - 63A6315B16665311006FC6A0 /* FMResultSet.h */, - 63A6315C16665311006FC6A0 /* FMResultSet.m */, - ); - path = FMDB; - sourceTree = ""; - }; 63A79240157506E600C863F3 = { isa = PBXGroup; children = ( - 63BF231016535D7F00F4F97C /* External */, - 63133C5915D4E5F0009A5BFC /* BeeDebugger */, - 63C3ABD815F7942600F411F5 /* BeeFramework */, + 63B46E6216A6BC180087C88C /* BeeDebugger */, + 63513D2E16A54436003422CA /* BeeFramework */, + 63513DF016A54436003422CA /* BeeTemplates */, + 63513DF916A54436003422CA /* External */, 63A79255157506E700C863F3 /* WhatsBug */, 63A7924E157506E700C863F3 /* Frameworks */, 63A7924C157506E700C863F3 /* Products */, @@ -715,162 +1079,61 @@ path = WhatsBug; sourceTree = ""; }; - 63BF231016535D7F00F4F97C /* External */ = { - isa = PBXGroup; - children = ( - 63A6315116665311006FC6A0 /* FMDB */, - 63BF231116535D7F00F4F97C /* ASI */, - 63BF232616535D7F00F4F97C /* JSONKit */, - 63BF232916535D7F00F4F97C /* Reachability */, - ); - name = External; - path = ../External; - sourceTree = ""; - }; - 63BF231116535D7F00F4F97C /* ASI */ = { - isa = PBXGroup; - children = ( - 63BF231216535D7F00F4F97C /* ASIAuthenticationDialog.h */, - 63BF231316535D7F00F4F97C /* ASIAuthenticationDialog.m */, - 63BF231416535D7F00F4F97C /* ASICacheDelegate.h */, - 63BF231516535D7F00F4F97C /* ASIDataCompressor.h */, - 63BF231616535D7F00F4F97C /* ASIDataCompressor.m */, - 63BF231716535D7F00F4F97C /* ASIDataDecompressor.h */, - 63BF231816535D7F00F4F97C /* ASIDataDecompressor.m */, - 63BF231916535D7F00F4F97C /* ASIDownloadCache.h */, - 63BF231A16535D7F00F4F97C /* ASIDownloadCache.m */, - 63BF231B16535D7F00F4F97C /* ASIFormDataRequest.h */, - 63BF231C16535D7F00F4F97C /* ASIFormDataRequest.m */, - 63BF231D16535D7F00F4F97C /* ASIHTTPRequest.h */, - 63BF231E16535D7F00F4F97C /* ASIHTTPRequest.m */, - 63BF231F16535D7F00F4F97C /* ASIHTTPRequestConfig.h */, - 63BF232016535D7F00F4F97C /* ASIHTTPRequestDelegate.h */, - 63BF232116535D7F00F4F97C /* ASIInputStream.h */, - 63BF232216535D7F00F4F97C /* ASIInputStream.m */, - 63BF232316535D7F00F4F97C /* ASINetworkQueue.h */, - 63BF232416535D7F00F4F97C /* ASINetworkQueue.m */, - 63BF232516535D7F00F4F97C /* ASIProgressDelegate.h */, - ); - path = ASI; - sourceTree = ""; - }; - 63BF232616535D7F00F4F97C /* JSONKit */ = { - isa = PBXGroup; - children = ( - 63BF232716535D7F00F4F97C /* JSONKit.h */, - 63BF232816535D7F00F4F97C /* JSONKit.m */, - ); - path = JSONKit; - sourceTree = ""; - }; - 63BF232916535D7F00F4F97C /* Reachability */ = { - isa = PBXGroup; - children = ( - 63BF232A16535D7F00F4F97C /* Reachability.h */, - 63BF232B16535D7F00F4F97C /* Reachability.m */, - ); - path = Reachability; - sourceTree = ""; - }; - 63C3ABD815F7942600F411F5 /* BeeFramework */ = { - isa = PBXGroup; - children = ( - 63A6314C16665155006FC6A0 /* Contributors.txt */, - 63A6314D16665163006FC6A0 /* License.txt */, - 63C3ABD915F7942600F411F5 /* Bee.h */, - 63A6314716664044006FC6A0 /* Bee_Precompile.h */, - 63C3ABF915F7942600F411F5 /* Foundation */, - 63C3AC1C15F7942600F411F5 /* MVC */, - 63A63150166652BB006FC6A0 /* Storage */, - ); - name = BeeFramework; - path = ../BeeFramework; - sourceTree = ""; - }; - 63C3ABF915F7942600F411F5 /* Foundation */ = { - isa = PBXGroup; - children = ( - 63C3ABFA15F7942600F411F5 /* Bee_Cache.h */, - 63C3ABFB15F7942600F411F5 /* Bee_Cache.m */, - 63BF2345165360FF00F4F97C /* Bee_Keychain.h */, - 63BF2346165360FF00F4F97C /* Bee_Keychain.m */, - 63C3ABFC15F7942600F411F5 /* Bee_Log.h */, - 63C3ABFD15F7942600F411F5 /* Bee_Log.mm */, - 63C3ABFE15F7942600F411F5 /* Bee_Network.h */, - 63C3ABFF15F7942600F411F5 /* Bee_Network.m */, - 63C3AC0015F7942600F411F5 /* Bee_Performance.h */, - 63C3AC0115F7942600F411F5 /* Bee_Performance.mm */, - 63C3AC0215F7942600F411F5 /* Bee_Runtime.h */, - 63C3AC0315F7942600F411F5 /* Bee_Runtime.mm */, - 63C3AC0415F7942600F411F5 /* Bee_Sandbox.h */, - 63C3AC0515F7942600F411F5 /* Bee_Sandbox.mm */, - 63C3AC0615F7942600F411F5 /* Bee_Singleton.h */, - 63C3AC0715F7942600F411F5 /* Bee_Singleton.mm */, - 63C3AC0815F7942600F411F5 /* Bee_SystemInfo.h */, - 63C3AC0915F7942600F411F5 /* Bee_SystemInfo.m */, - 63C3AC0A15F7942600F411F5 /* Bee_Thread.h */, - 63C3AC0B15F7942600F411F5 /* Bee_Thread.mm */, - 63C3AC0C15F7942600F411F5 /* NSArray+BeeExtension.h */, - 63C3AC0D15F7942600F411F5 /* NSArray+BeeExtension.m */, - 63C3AC0E15F7942600F411F5 /* NSData+BeeExtension.h */, - 63C3AC0F15F7942600F411F5 /* NSData+BeeExtension.m */, - 63926914164D49D50099625C /* NSDate+BeeExtension.h */, - 63926915164D49D90099625C /* NSDate+BeeExtension.m */, - 63C3AC1015F7942600F411F5 /* NSDictionary+BeeExtension.h */, - 63C3AC1115F7942600F411F5 /* NSDictionary+BeeExtension.m */, - 63C3AC1215F7942600F411F5 /* NSNumber+BeeExtension.h */, - 63C3AC1315F7942600F411F5 /* NSNumber+BeeExtension.m */, - 63C3AC1415F7942600F411F5 /* NSObject+BeeNotification.h */, - 63C3AC1515F7942600F411F5 /* NSObject+BeeNotification.m */, - 63C3AC1615F7942600F411F5 /* NSObject+BeeProperty.h */, - 63C3AC1715F7942600F411F5 /* NSObject+BeeProperty.m */, - 63C3AC1815F7942600F411F5 /* NSObject+BeeTicker.h */, - 63C3AC1915F7942600F411F5 /* NSObject+BeeTicker.m */, - 63C3AC1A15F7942600F411F5 /* NSString+BeeExtension.h */, - 63C3AC1B15F7942600F411F5 /* NSString+BeeExtension.m */, - ); - path = Foundation; - sourceTree = ""; - }; - 63C3AC1C15F7942600F411F5 /* MVC */ = { + 63B46E6216A6BC180087C88C /* BeeDebugger */ = { isa = PBXGroup; children = ( - 63C3AC1D15F7942600F411F5 /* Bee_Controller.h */, - 63C3AC1E15F7942600F411F5 /* Bee_Controller.mm */, - 63C3AC1F15F7942600F411F5 /* Bee_Model.h */, - 63C3AC2015F7942600F411F5 /* Bee_Model.m */, - 63C3AC2115F7942600F411F5 /* Bee_View.h */, - 63C3AC2215F7942600F411F5 /* Bee_View.m */, - 639268A8164CF7460099625C /* View */, - 63C3AC5015F7942600F411F5 /* ViewController */, + 63B46E6316A6BC180087C88C /* Bee_Debug.h */, + 63B46E6416A6BC180087C88C /* Bee_Debug.m */, + 63B46E6516A6BC180087C88C /* Bee_DebugCrashReporter.h */, + 63B46E6616A6BC180087C88C /* Bee_DebugCrashReporter.mm */, + 63B46E6716A6BC180087C88C /* Bee_DebugDashBoard.h */, + 63B46E6816A6BC180087C88C /* Bee_DebugDashBoard.m */, + 63B46E6916A6BC180087C88C /* Bee_DebugDetailView.h */, + 63B46E6A16A6BC180087C88C /* Bee_DebugDetailView.m */, + 63B46E6B16A6BC180087C88C /* Bee_DebugHeatmapModel.h */, + 63B46E6C16A6BC180087C88C /* Bee_DebugHeatmapModel.m */, + 63B46E6D16A6BC180087C88C /* Bee_DebugMemoryModel.h */, + 63B46E6E16A6BC180087C88C /* Bee_DebugMemoryModel.m */, + 63B46E6F16A6BC180087C88C /* Bee_DebugMessageBoard.h */, + 63B46E7016A6BC180087C88C /* Bee_DebugMessageBoard.m */, + 63B46E7116A6BC180087C88C /* Bee_DebugMessageModel.h */, + 63B46E7216A6BC180087C88C /* Bee_DebugMessageModel.m */, + 63B46E7316A6BC180087C88C /* Bee_DebugNetworkBoard.h */, + 63B46E7416A6BC180087C88C /* Bee_DebugNetworkBoard.m */, + 63B46E7516A6BC180087C88C /* Bee_DebugNetworkModel.h */, + 63B46E7616A6BC180087C88C /* Bee_DebugNetworkModel.m */, + 63B46E7716A6BC180087C88C /* Bee_DebugPieView.h */, + 63B46E7816A6BC180087C88C /* Bee_DebugPieView.m */, + 63B46E7916A6BC180087C88C /* Bee_DebugPlotsView.h */, + 63B46E7A16A6BC180087C88C /* Bee_DebugPlotsView.m */, + 63B46E7B16A6BC180087C88C /* Bee_DebugSampleView.h */, + 63B46E7C16A6BC180087C88C /* Bee_DebugSampleView.m */, + 63B46E7D16A6BC180087C88C /* Bee_DebugSandboxBoard.h */, + 63B46E7E16A6BC180087C88C /* Bee_DebugSandboxBoard.m */, + 63B46E7F16A6BC180087C88C /* Bee_DebugUtility.h */, + 63B46E8016A6BC180087C88C /* Bee_DebugUtility.m */, + 63B46E8116A6BC180087C88C /* Bee_DebugViewBoard.h */, + 63B46E8216A6BC180087C88C /* Bee_DebugViewBoard.m */, + 63B46E8316A6BC180087C88C /* Bee_DebugViewModel.h */, + 63B46E8416A6BC180087C88C /* Bee_DebugViewModel.m */, + 63B46E8516A6BC180087C88C /* Bee_DebugWindow.h */, + 63B46E8616A6BC180087C88C /* Bee_DebugWindow.m */, + 63B46E8716A6BC180087C88C /* bug@2x.png */, + 63B46E8816A6BC180087C88C /* close@2x.png */, + 63B46E8916A6BC180087C88C /* file@2x.png */, + 63B46E8A16A6BC180087C88C /* folder@2x.png */, + 63B46E8B16A6BC180087C88C /* heat@2x.png */, + 63B46E8C16A6BC180087C88C /* tap@2x.png */, ); - path = MVC; - sourceTree = ""; - }; - 63C3AC5015F7942600F411F5 /* ViewController */ = { - isa = PBXGroup; - children = ( - 63C3AC5115F7942600F411F5 /* Bee_UIBoard.h */, - 63C3AC5215F7942600F411F5 /* Bee_UIBoard.m */, - 63F8E90D160C595300A5FECC /* Bee_UICameraBoard.h */, - 63F8E90E160C595300A5FECC /* Bee_UICameraBoard.m */, - 63C3AC5315F7942600F411F5 /* Bee_UIFlowBoard.h */, - 63C3AC5415F7942600F411F5 /* Bee_UIFlowtBoard.m */, - 63C3AC5515F7942600F411F5 /* Bee_UIStack.h */, - 63C3AC5615F7942600F411F5 /* Bee_UIStack.m */, - 63C3AC5715F7942600F411F5 /* Bee_UIStackGroup.h */, - 63C3AC5815F7942600F411F5 /* Bee_UIStackGroup.m */, - 63C3AC5915F7942600F411F5 /* Bee_UITableBoard.h */, - 63C3AC5A15F7942600F411F5 /* Bee_UITableBoard.m */, - 63C3AC5B15F7942600F411F5 /* Bee_UIWebBoard.h */, - 63C3AC5C15F7942600F411F5 /* Bee_UIWebBoard.m */, - ); - path = ViewController; + name = BeeDebugger; + path = ../BeeDebugger; sourceTree = ""; }; 63FE1C2A15D0191C00432794 /* WhatsBug */ = { isa = PBXGroup; children = ( + 633EFE04168461BD00F1B27A /* iPad.xib */, + 633EFE06168461D200F1B27A /* iPhone.xib */, 63FE1C2B15D0191C00432794 /* AppDelegate.h */, 63FE1C2C15D0191C00432794 /* AppDelegate.m */, 63EAE481166E2C5500C6F40E /* Default-568h@2x.png */, @@ -941,15 +1204,15 @@ 63FE1C4515D0191C00432794 /* Default@2x.png in Resources */, 63FE1C4615D0191C00432794 /* icon.png in Resources */, 63FE1C4715D0191C00432794 /* icon@2x.png in Resources */, - 63133C8515D4E5F0009A5BFC /* bug@2x.png in Resources */, - 63133C8615D4E5F0009A5BFC /* close@2x.png in Resources */, - 63133C8715D4E5F0009A5BFC /* file@2x.png in Resources */, - 63133C8815D4E5F0009A5BFC /* folder@2x.png in Resources */, - 6392692B164F99320099625C /* tap@2x.png in Resources */, - 6392692D164F9CEF0099625C /* heat@2x.png in Resources */, - 63A6314E16665170006FC6A0 /* Contributors.txt in Resources */, - 63A6314F16665170006FC6A0 /* License.txt in Resources */, 63EAE482166E2C5500C6F40E /* Default-568h@2x.png in Resources */, + 633EFE05168461BD00F1B27A /* iPad.xib in Resources */, + 633EFE07168461D200F1B27A /* iPhone.xib in Resources */, + 63B46E9F16A6BC180087C88C /* bug@2x.png in Resources */, + 63B46EA016A6BC180087C88C /* close@2x.png in Resources */, + 63B46EA116A6BC180087C88C /* file@2x.png in Resources */, + 63B46EA216A6BC180087C88C /* folder@2x.png in Resources */, + 63B46EA316A6BC180087C88C /* heat@2x.png in Resources */, + 63B46EA416A6BC180087C88C /* tap@2x.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -962,48 +1225,6 @@ files = ( 63FE1C4315D0191C00432794 /* AppDelegate.m in Sources */, 63FE1C4815D0191C00432794 /* main.m in Sources */, - 63133C7815D4E5F0009A5BFC /* Bee_Debug.m in Sources */, - 63133C7E15D4E5F0009A5BFC /* Bee_DebugMessageBoard.m in Sources */, - 63133C7F15D4E5F0009A5BFC /* Bee_DebugDetailView.m in Sources */, - 63133C8015D4E5F0009A5BFC /* Bee_DebugPieView.m in Sources */, - 63133C8115D4E5F0009A5BFC /* Bee_DebugPlotsView.m in Sources */, - 63133C8215D4E5F0009A5BFC /* Bee_DebugSampleView.m in Sources */, - 63133C8415D4E5F0009A5BFC /* Bee_DebugWindow.m in Sources */, - 63133C9115D8A7A3009A5BFC /* Bee_DebugSandboxBoard.m in Sources */, - 63133C9415D8B39C009A5BFC /* Bee_DebugUtility.m in Sources */, - 63133C9D15D8BF1E009A5BFC /* Bee_DebugNetworkBoard.m in Sources */, - 63AFC78715DB522100100B4F /* Bee_DebugViewBoard.m in Sources */, - 63AFC79D15DE3EA500100B4F /* Bee_DebugMemoryModel.m in Sources */, - 63AFC7A015DE410300100B4F /* Bee_DebugMessageModel.m in Sources */, - 63AFC7A315DE457500100B4F /* Bee_DebugNetworkModel.m in Sources */, - 63AFC7A615DE475E00100B4F /* Bee_DebugDashBoard.m in Sources */, - 63C3AC6815F7942600F411F5 /* Bee_Cache.m in Sources */, - 63C3AC6915F7942600F411F5 /* Bee_Log.mm in Sources */, - 63C3AC6A15F7942600F411F5 /* Bee_Network.m in Sources */, - 63C3AC6B15F7942600F411F5 /* Bee_Performance.mm in Sources */, - 63C3AC6C15F7942600F411F5 /* Bee_Runtime.mm in Sources */, - 63C3AC6D15F7942600F411F5 /* Bee_Sandbox.mm in Sources */, - 63C3AC6E15F7942600F411F5 /* Bee_Singleton.mm in Sources */, - 63C3AC6F15F7942600F411F5 /* Bee_SystemInfo.m in Sources */, - 63C3AC7015F7942600F411F5 /* Bee_Thread.mm in Sources */, - 63C3AC7115F7942600F411F5 /* NSArray+BeeExtension.m in Sources */, - 63C3AC7215F7942600F411F5 /* NSData+BeeExtension.m in Sources */, - 63C3AC7315F7942600F411F5 /* NSDictionary+BeeExtension.m in Sources */, - 63C3AC7415F7942600F411F5 /* NSNumber+BeeExtension.m in Sources */, - 63C3AC7515F7942600F411F5 /* NSObject+BeeNotification.m in Sources */, - 63C3AC7615F7942600F411F5 /* NSObject+BeeProperty.m in Sources */, - 63C3AC7715F7942600F411F5 /* NSObject+BeeTicker.m in Sources */, - 63C3AC7815F7942600F411F5 /* NSString+BeeExtension.m in Sources */, - 63C3AC7915F7942600F411F5 /* Bee_Controller.mm in Sources */, - 63C3AC7A15F7942600F411F5 /* Bee_Model.m in Sources */, - 63C3AC7B15F7942600F411F5 /* Bee_View.m in Sources */, - 63C3AC9215F7942600F411F5 /* Bee_UIBoard.m in Sources */, - 63C3AC9315F7942600F411F5 /* Bee_UIFlowtBoard.m in Sources */, - 63C3AC9415F7942600F411F5 /* Bee_UIStack.m in Sources */, - 63C3AC9515F7942600F411F5 /* Bee_UIStackGroup.m in Sources */, - 63C3AC9615F7942600F411F5 /* Bee_UITableBoard.m in Sources */, - 63C3AC9715F7942600F411F5 /* Bee_UIWebBoard.m in Sources */, - 63F8E90F160C595300A5FECC /* Bee_UICameraBoard.m in Sources */, 6392688F164CEF600099625C /* CatelogBoard.m in Sources */, 63926890164CEF600099625C /* DribbbleBoard.m in Sources */, 63926891164CEF600099625C /* DribbbleController.mm in Sources */, @@ -1028,60 +1249,130 @@ 639268A5164CEF600099625C /* Lession9Board.m in Sources */, 639268A6164CEF600099625C /* Lession9Controller.m in Sources */, 639268A7164CEF600099625C /* LessionBaseBoard.m in Sources */, - 639268E3164CF7460099625C /* Bee_UIActionSheet.m in Sources */, - 639268E4164CF7460099625C /* Bee_UIActivityIndicatorView.m in Sources */, - 639268E5164CF7460099625C /* Bee_UIAlertView.m in Sources */, - 639268E6164CF7460099625C /* Bee_UIButton.m in Sources */, - 639268E8164CF7460099625C /* Bee_UIDatePicker.m in Sources */, - 639268EA164CF7460099625C /* Bee_UIGridCell.m in Sources */, - 639268EB164CF7460099625C /* Bee_UIImageView.m in Sources */, - 639268EC164CF7460099625C /* Bee_UIKeyboard.m in Sources */, - 639268ED164CF7460099625C /* Bee_UILabel.m in Sources */, - 639268EF164CF7460099625C /* Bee_UIOrientation.m in Sources */, - 639268F0164CF7460099625C /* Bee_UIPageControl.m in Sources */, - 639268F1164CF7460099625C /* Bee_UIProgressView.m in Sources */, - 639268F2164CF7460099625C /* Bee_UIPullLoader.m in Sources */, - 639268F4164CF7460099625C /* Bee_UIScrollView.m in Sources */, - 639268F5164CF7460099625C /* Bee_UISegmentedControl.m in Sources */, - 639268F6164CF7460099625C /* Bee_UISignal.m in Sources */, - 639268F7164CF7460099625C /* Bee_UITabBar.m in Sources */, - 639268F8164CF7460099625C /* Bee_UITextField.m in Sources */, - 639268F9164CF7460099625C /* Bee_UITextView.m in Sources */, - 639268FB164CF7460099625C /* Bee_UIWebView.m in Sources */, - 639268FC164CF7460099625C /* Bee_UIZoomView.m in Sources */, - 639268FE164CF7460099625C /* UIView+BeeQuery.m in Sources */, - 639268FF164CF7460099625C /* UIView+BeeWireframe.m in Sources */, - 63926902164CFABE0099625C /* UIColor+BeeExtension.m in Sources */, - 63926905164CFB470099625C /* UIFont+BeeExtension.m in Sources */, - 6392690B164CFE510099625C /* CGRect+BeeExtension.m in Sources */, - 6392690E164CFFBE0099625C /* UIImage+BeeExtension.m in Sources */, - 63926911164D1F580099625C /* UIView+BeeBackground.m in Sources */, - 63926916164D49DC0099625C /* NSDate+BeeExtension.m in Sources */, - 6392691C164F88D50099625C /* Bee_DebugHeatmapModel.m in Sources */, - 63BF232F16535D7F00F4F97C /* ASIAuthenticationDialog.m in Sources */, - 63BF233016535D7F00F4F97C /* ASIDataCompressor.m in Sources */, - 63BF233116535D7F00F4F97C /* ASIDataDecompressor.m in Sources */, - 63BF233216535D7F00F4F97C /* ASIDownloadCache.m in Sources */, - 63BF233316535D7F00F4F97C /* ASIFormDataRequest.m in Sources */, - 63BF233416535D7F00F4F97C /* ASIHTTPRequest.m in Sources */, - 63BF233516535D7F00F4F97C /* ASIInputStream.m in Sources */, - 63BF233616535D7F00F4F97C /* ASINetworkQueue.m in Sources */, - 63BF233716535D7F00F4F97C /* JSONKit.m in Sources */, - 63BF233816535D7F00F4F97C /* Reachability.m in Sources */, - 63BF2347165360FF00F4F97C /* Bee_Keychain.m in Sources */, - 63D5116316593A39005948E3 /* Bee_DebugViewModel.m in Sources */, - 63D5116916596495005948E3 /* Bee_DebugCrashReporter.mm in Sources */, - 63A6315D16665311006FC6A0 /* FMDatabase.m in Sources */, - 63A6315E16665311006FC6A0 /* FMDatabaseAdditions.m in Sources */, - 63A6315F16665311006FC6A0 /* FMDatabasePool.m in Sources */, - 63A6316016665311006FC6A0 /* FMDatabaseQueue.m in Sources */, - 63A6316216665311006FC6A0 /* FMResultSet.m in Sources */, - 63A63165166657D6006FC6A0 /* Bee_Database.m in Sources */, - 63A63168166657EE006FC6A0 /* Bee_ActiveRecord.m in Sources */, - 633F6DFC166A7D870079B3C9 /* Bee_DatabaseTest.m in Sources */, - 633F6DFF166B88EA0079B3C9 /* Bee_ActiveRecordTest.m in Sources */, 63F5FB6F166CE38B00139103 /* Lession11Board.m in Sources */, 63F5FB73166CE53900139103 /* Lession11Model.m in Sources */, + 63513E5016A54436003422CA /* Bee_Foundation.mm in Sources */, + 63513E5116A54436003422CA /* Bee_Log.mm in Sources */, + 63513E5216A54436003422CA /* Bee_Performance.mm in Sources */, + 63513E5316A54436003422CA /* Bee_Runtime.mm in Sources */, + 63513E5416A54436003422CA /* Bee_Sandbox.mm in Sources */, + 63513E5516A54436003422CA /* Bee_Singleton.mm in Sources */, + 63513E5616A54436003422CA /* Bee_SystemInfo.m in Sources */, + 63513E5716A54436003422CA /* Bee_Thread.mm in Sources */, + 63513E5816A54436003422CA /* NSArray+BeeExtension.m in Sources */, + 63513E5916A54436003422CA /* NSData+BeeExtension.m in Sources */, + 63513E5A16A54436003422CA /* NSDate+BeeExtension.m in Sources */, + 63513E5B16A54436003422CA /* NSDictionary+BeeExtension.m in Sources */, + 63513E5C16A54436003422CA /* NSNumber+BeeExtension.m in Sources */, + 63513E5D16A54436003422CA /* NSObject+BeeNotification.m in Sources */, + 63513E5E16A54436003422CA /* NSObject+BeeProperty.m in Sources */, + 63513E5F16A54436003422CA /* NSObject+BeeTicker.m in Sources */, + 63513E6016A54436003422CA /* NSObject+BeeTypeConversion.m in Sources */, + 63513E6116A54436003422CA /* NSString+BeeExtension.m in Sources */, + 63513E6216A54436003422CA /* Bee_Network.m in Sources */, + 63513E6316A54436003422CA /* Bee_Request.m in Sources */, + 63513E6416A54436003422CA /* Bee_RequestQueue.m in Sources */, + 63513E6516A54436003422CA /* NSObject+BeeRequest.m in Sources */, + 63513E6616A54436003422CA /* Bee_ActiveBase.m in Sources */, + 63513E6716A54436003422CA /* Bee_ActiveBaseTest.m in Sources */, + 63513E6816A54436003422CA /* Bee_ActiveRecord.m in Sources */, + 63513E6916A54436003422CA /* Bee_ActiveRecordTest.m in Sources */, + 63513E6A16A54436003422CA /* Bee_Cache.m in Sources */, + 63513E6B16A54436003422CA /* Bee_CacheTest.m in Sources */, + 63513E6C16A54436003422CA /* Bee_Database.m in Sources */, + 63513E6D16A54436003422CA /* Bee_DatabaseTest.m in Sources */, + 63513E6E16A54436003422CA /* Bee_Keychain.m in Sources */, + 63513E6F16A54436003422CA /* Bee_KeychainTest.m in Sources */, + 63513E7016A54436003422CA /* Bee_Storage.m in Sources */, + 63513E7116A54436003422CA /* NSObject+BeeDatabase.m in Sources */, + 63513E7216A54436003422CA /* NSObject+BeeKeychain.m in Sources */, + 63513E7316A54436003422CA /* Bee_UnitTest.m in Sources */, + 63513E7516A54436003422CA /* Bee_Controller.mm in Sources */, + 63513E7616A54436003422CA /* Bee_Message.mm in Sources */, + 63513E7716A54436003422CA /* Bee_MessageQueue.mm in Sources */, + 63513E7816A54436003422CA /* BeeMessage+ActiveRecord.m in Sources */, + 63513E7916A54436003422CA /* BeeMessage+HTTP.mm in Sources */, + 63513E7A16A54436003422CA /* BeeMessage+JSON.mm in Sources */, + 63513E7B16A54436003422CA /* BeeMessage+XML.mm in Sources */, + 63513E7C16A54436003422CA /* NSObject+BeeMessage.mm in Sources */, + 63513E7D16A54436003422CA /* Bee_Model.m in Sources */, + 63513E7E16A54436003422CA /* Bee_UIActionSheet.m in Sources */, + 63513E7F16A54436003422CA /* Bee_UIActivityIndicatorView.m in Sources */, + 63513E8016A54436003422CA /* Bee_UIAlertView.m in Sources */, + 63513E8116A54436003422CA /* Bee_UIButton.m in Sources */, + 63513E8216A54436003422CA /* Bee_UIDatePicker.m in Sources */, + 63513E8316A54436003422CA /* Bee_UIGridCell.m in Sources */, + 63513E8416A54436003422CA /* Bee_UIImageView.m in Sources */, + 63513E8516A54436003422CA /* Bee_UIKeyboard.m in Sources */, + 63513E8616A54436003422CA /* Bee_UILabel.m in Sources */, + 63513E8716A54436003422CA /* Bee_UIOrientation.m in Sources */, + 63513E8816A54436003422CA /* Bee_UIPageControl.m in Sources */, + 63513E8916A54436003422CA /* Bee_UIProgressView.m in Sources */, + 63513E8A16A54436003422CA /* Bee_UIPullLoader.m in Sources */, + 63513E8B16A54436003422CA /* Bee_UIScrollView.m in Sources */, + 63513E8C16A54436003422CA /* Bee_UISegmentedControl.m in Sources */, + 63513E8D16A54436003422CA /* Bee_UISignal.m in Sources */, + 63513E8E16A54436003422CA /* Bee_UITabBar.m in Sources */, + 63513E8F16A54436003422CA /* Bee_UITextField.m in Sources */, + 63513E9016A54436003422CA /* Bee_UITextView.m in Sources */, + 63513E9116A54436003422CA /* Bee_UITipsView.m in Sources */, + 63513E9216A54436003422CA /* Bee_UIWebView.m in Sources */, + 63513E9316A54436003422CA /* Bee_UIZoomView.m in Sources */, + 63513E9416A54436003422CA /* Bee_View.m in Sources */, + 63513E9516A54436003422CA /* CGRect+BeeExtension.m in Sources */, + 63513E9716A54436003422CA /* UIColor+BeeExtension.m in Sources */, + 63513E9816A54436003422CA /* UIFont+BeeExtension.m in Sources */, + 63513E9916A54436003422CA /* UIImage+BeeExtension.m in Sources */, + 63513E9A16A54436003422CA /* UIView+BeeExtension.m in Sources */, + 63513E9B16A54436003422CA /* UIView+BeeUISignal.m in Sources */, + 63513E9C16A54436003422CA /* UIView+HoldGesture.m in Sources */, + 63513E9D16A54436003422CA /* UIView+PanGesture.m in Sources */, + 63513E9E16A54436003422CA /* UIView+SwipeGesture.m in Sources */, + 63513E9F16A54436003422CA /* UIView+TapGesture.m in Sources */, + 63513EA016A54436003422CA /* Bee_UIBoard.m in Sources */, + 63513EA116A54436003422CA /* Bee_UIStack.m in Sources */, + 63513EA216A54436003422CA /* Bee_UIStackGroup.m in Sources */, + 63513EA316A54436003422CA /* Bee_ViewController.m in Sources */, + 63513EA416A54436003422CA /* UIViewController+BeeExtension.m in Sources */, + 63513EA516A54436003422CA /* UIViewController+BeeUISignal.m in Sources */, + 63513EA616A54436003422CA /* UIViewController+UINavigationBar.m in Sources */, + 63513EAD16A54436003422CA /* ASIAuthenticationDialog.m in Sources */, + 63513EAE16A54436003422CA /* ASIDataCompressor.m in Sources */, + 63513EAF16A54436003422CA /* ASIDataDecompressor.m in Sources */, + 63513EB016A54436003422CA /* ASIDownloadCache.m in Sources */, + 63513EB116A54436003422CA /* ASIFormDataRequest.m in Sources */, + 63513EB216A54436003422CA /* ASIHTTPRequest.m in Sources */, + 63513EB316A54436003422CA /* ASIInputStream.m in Sources */, + 63513EB416A54436003422CA /* ASINetworkQueue.m in Sources */, + 63513EB516A54436003422CA /* FMDatabase.m in Sources */, + 63513EB616A54436003422CA /* FMDatabaseAdditions.m in Sources */, + 63513EB716A54436003422CA /* FMDatabasePool.m in Sources */, + 63513EB816A54436003422CA /* FMDatabaseQueue.m in Sources */, + 63513EB916A54436003422CA /* FMResultSet.m in Sources */, + 63513EBA16A54436003422CA /* JSONKit.m in Sources */, + 63513EBB16A54436003422CA /* Reachability.m in Sources */, + 63B46E8D16A6BC180087C88C /* Bee_Debug.m in Sources */, + 63B46E8E16A6BC180087C88C /* Bee_DebugCrashReporter.mm in Sources */, + 63B46E8F16A6BC180087C88C /* Bee_DebugDashBoard.m in Sources */, + 63B46E9016A6BC180087C88C /* Bee_DebugDetailView.m in Sources */, + 63B46E9116A6BC180087C88C /* Bee_DebugHeatmapModel.m in Sources */, + 63B46E9216A6BC180087C88C /* Bee_DebugMemoryModel.m in Sources */, + 63B46E9316A6BC180087C88C /* Bee_DebugMessageBoard.m in Sources */, + 63B46E9416A6BC180087C88C /* Bee_DebugMessageModel.m in Sources */, + 63B46E9516A6BC180087C88C /* Bee_DebugNetworkBoard.m in Sources */, + 63B46E9616A6BC180087C88C /* Bee_DebugNetworkModel.m in Sources */, + 63B46E9716A6BC180087C88C /* Bee_DebugPieView.m in Sources */, + 63B46E9816A6BC180087C88C /* Bee_DebugPlotsView.m in Sources */, + 63B46E9916A6BC180087C88C /* Bee_DebugSampleView.m in Sources */, + 63B46E9A16A6BC180087C88C /* Bee_DebugSandboxBoard.m in Sources */, + 63B46E9B16A6BC180087C88C /* Bee_DebugUtility.m in Sources */, + 63B46E9C16A6BC180087C88C /* Bee_DebugViewBoard.m in Sources */, + 63B46E9D16A6BC180087C88C /* Bee_DebugViewModel.m in Sources */, + 63B46E9E16A6BC180087C88C /* Bee_DebugWindow.m in Sources */, + 63560A5D16AFCA3700F959AA /* Bee_UICameraBoard.m in Sources */, + 63560A5E16AFCA3700F959AA /* Bee_UIFlowBoard.m in Sources */, + 63560A5F16AFCA3700F959AA /* Bee_UITableBoard.m in Sources */, + 63560A6016AFCA3700F959AA /* Bee_UIWebBoard.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Example/WhatsBug/AppDelegate.m b/Example/WhatsBug/AppDelegate.m index 1a21767..11e4ff0 100644 --- a/Example/WhatsBug/AppDelegate.m +++ b/Example/WhatsBug/AppDelegate.m @@ -9,8 +9,9 @@ #import "Bee.h" #import "Bee_Debug.h" -#import "Bee_DatabaseTest.h" -#import "Bee_ActiveRecordTest.h" + +#pragma mark - +#pragma mark UnitTest @implementation AppDelegate @@ -47,7 +48,7 @@ - (void) onCrash_unimplementedSelector - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - PRINT_CALLSTACK( 32 ); + [BeeUnitTest runTests]; self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; self.window.backgroundColor = [UIColor whiteColor]; @@ -55,9 +56,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( [self.window makeKeyAndVisible]; [BeeDebugger show]; - [BeeDatabaseTest run]; - [BeeActiveRecordTest run]; - + // [self onCrash_unimplementedSelector]; return YES; diff --git a/Example/WhatsBug/iPad.xib b/Example/WhatsBug/iPad.xib new file mode 100644 index 0000000..6d7c245 --- /dev/null +++ b/Example/WhatsBug/iPad.xib @@ -0,0 +1,75 @@ + + + + 1536 + 12A206j + 2519 + 1172.1 + 613.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 1856 + + + IBProxyObject + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + PluginDependencyRecalculationVersion + + + + + IBFilesOwner + IBIPadFramework + + + IBFirstResponder + IBIPadFramework + + + + + + + + 0 + + + + + + -1 + + + File's Owner + + + -2 + + + + + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIResponder + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + + 1 + + + 0 + IBIPadFramework + YES + 3 + YES + 1856 + + diff --git a/Example/WhatsBug/iPhone.xib b/Example/WhatsBug/iPhone.xib new file mode 100644 index 0000000..d7696d4 --- /dev/null +++ b/Example/WhatsBug/iPhone.xib @@ -0,0 +1,704 @@ + + + + 1536 + 11E53 + 2844 + 1138.47 + 569.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 1930 + + + IBNSLayoutConstraint + IBProxyObject + IBUIDatePicker + IBUINavigationBar + IBUISearchBar + IBUITabBar + IBUITabBarItem + IBUITableView + IBUIView + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + PluginDependencyRecalculationVersion + + + + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + + 292 + + + + 266 + {{0, 519}, {320, 49}} + + + _NS:9 + + 3 + MCAwAA + + IBCocoaTouchFramework + + + IBCocoaTouchFramework + + 1 + + + IBCocoaTouchFramework + + 0 + + + + + + 290 + {320, 44} + + + _NS:9 + IBCocoaTouchFramework + 1 + + + + + 290 + {{0, 44}, {320, 44}} + + + _NS:9 + 3 + IBCocoaTouchFramework + 1 + + IBCocoaTouchFramework + + + + + 290 + {{0, 303}, {320, 216}} + + + _NS:9 + IBCocoaTouchFramework + 0 + 0 + + America/Los_Angeles + + VFppZgAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABAAAAAAAAAC5AAAABAAAABCepkign7sVkKCGKqChmveQ +y4kaoNIj9HDSYSYQ1v50INiArZDa/tGg28CQENzes6DdqayQ3r6VoN+JjpDgnneg4WlwkOJ+WaDjSVKQ +5F47oOUpNJDmR1gg5xJREOgnOiDo8jMQ6gccIOrSFRDr5v4g7LH3EO3G4CDukdkQ76/8oPBxuxDxj96g +8n/BkPNvwKD0X6OQ9U+ioPY/hZD3L4Sg+CiiEPkPZqD6CIQQ+viDIPvoZhD82GUg/chIEP64RyD/qCoQ +AJgpIAGIDBACeAsgA3EokARhJ6AFUQqQBkEJoAcw7JAHjUOgCRDOkAmtvyAK8LCQC+CvoAzZzRANwJGg +DrmvEA+priAQmZEQEYmQIBJ5cxATaXIgFFlVEBVJVCAWOTcQFyk2IBgiU5AZCRggGgI1kBryNKAb4heQ +HNIWoB3B+ZAesfigH6HbkCB2KyAhgb2QIlYNICNq2hAkNe8gJUq8ECYV0SAnKp4QJ/7toCkKgBAp3s+g +KupiECu+saAs036QLZ6ToC6zYJAvfnWgMJNCkDFnkiAycySQM0d0IDRTBpA1J1YgNjLokDcHOCA4HAUQ +OOcaIDn75xA6xvwgO9vJEDywGKA9u6sQPo/6oD+bjRBAb9ygQYSpkEJPvqBDZIuQRC+goEVEbZBF89Mg +Ry2KEEfTtSBJDWwQSbOXIErtThBLnLOgTNZqkE18laBOtkyQT1x3oFCWLpBRPFmgUnYQkFMcO6BUVfKQ +VPwdoFY11JBW5TogWB7xEFjFHCBZ/tMQWqT+IFvetRBchOAgXb6XEF5kwiBfnnkQYE3eoGGHlZBiLcCg +Y2d3kGQNoqBlR1mQZe2EoGcnO5BnzWagaQcdkGmtSKBq5v+Qa5ZlIGzQHBBtdkcgbq/+EG9WKSBwj+AQ +cTYLIHJvwhBzFe0gdE+kEHT/CaB2OMCQdt7roHgYopB4vs2gefiEkHqer6B72GaQfH6RoH24SJB+XnOg +f5gqkAABAAECAwEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA +AQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA +AQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEAAQABAAEA +AQABAAEAAQAB//+dkAEA//+PgAAE//+dkAEI//+dkAEMUERUAFBTVABQV1QAUFBUAAAAAAEAAAABA + + + + 377774741.56858402 + + 1 + + + + 274 + {{0, 88}, {320, 215}} + + + _NS:9 + + 3 + MQA + + YES + IBCocoaTouchFramework + YES + 1 + 0 + YES + 44 + 22 + 22 + + + {320, 568} + + + _NS:9 + + 3 + MQA + + 2 + + + + IBUIScreenMetrics + + YES + + + + + + {320, 568} + {568, 320} + + + IBCocoaTouchFramework + Retina 4 Full Screen + 2 + + MyView + IBCocoaTouchFramework + + + + + + + + 0 + + + + + + -1 + + + File's Owner + + + -2 + + + + + 8 + + + + + 4 + 0 + + 4 + 1 + + 0.0 + + 1000 + + 8 + 29 + 3 + + + + 6 + 0 + + 6 + 1 + + 0.0 + + 1000 + + 8 + 29 + 3 + + + + 5 + 0 + + 5 + 1 + + 0.0 + + 1000 + + 8 + 29 + 3 + + + + 5 + 0 + + 5 + 1 + + 0.0 + + 1000 + + 8 + 29 + 3 + + + + 6 + 0 + + 6 + 1 + + 0.0 + + 1000 + + 8 + 29 + 3 + + + + 4 + 0 + + 3 + 1 + + 0.0 + + 1000 + + 6 + 24 + 3 + + + + 6 + 0 + + 6 + 1 + + 0.0 + + 1000 + + 8 + 29 + 3 + + + + 3 + 0 + + 4 + 1 + + 0.0 + + 1000 + + 6 + 24 + 3 + + + + 5 + 0 + + 5 + 1 + + 0.0 + + 1000 + + 8 + 29 + 3 + + + + 6 + 0 + + 6 + 1 + + 0.0 + + 1000 + + 8 + 29 + 3 + + + + 3 + 0 + + 4 + 1 + + 0.0 + + 1000 + + 6 + 24 + 3 + + + + 5 + 0 + + 5 + 1 + + 0.0 + + 1000 + + 8 + 29 + 3 + + + + 6 + 0 + + 6 + 1 + + 0.0 + + 1000 + + 8 + 29 + 3 + + + + 3 + 0 + + 3 + 1 + + 0.0 + + 1000 + + 8 + 29 + 3 + + + + 5 + 0 + + 5 + 1 + + 0.0 + + 1000 + + 8 + 29 + 3 + + + + + + + + + + + 5 + + + + + + + + + 7 + + + + + 6 + + + + + 9 + + + + + 11 + + + + + 12 + + + + + 13 + + + + + + 15 + + + + + 16 + + + + + 17 + + + + + 19 + + + + + 22 + + + + + 23 + + + + + 24 + + + + + 25 + + + + + 8 + 0 + + 0 + 1 + + 216 + + 1000 + + 3 + 9 + 1 + + + + + + 26 + + + + + 27 + + + + + 28 + + + + + 29 + + + + + 36 + + + + + 8 + 0 + + 0 + 1 + + 215 + + 1000 + + 3 + 9 + 1 + + + + + + 37 + + + + + 38 + + + + + 41 + + + + + 42 + + + + + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + UIResponder + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + + + + + + + + + + + + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + + 42 + + + + + NSLayoutConstraint + NSObject + + IBProjectSource + ./Classes/NSLayoutConstraint.h + + + + + 0 + IBCocoaTouchFramework + YES + 3 + YES + 1930 + + diff --git a/BeeFramework/License.txt b/License.txt old mode 100755 new mode 100644 similarity index 100% rename from BeeFramework/License.txt rename to License.txt