diff --git a/Classes/JCStockGraphController.h b/Classes/JCStockGraphController.h index 9ca931b..5d54dd1 100755 --- a/Classes/JCStockGraphController.h +++ b/Classes/JCStockGraphController.h @@ -10,11 +10,11 @@ #import "CorePlot-CocoaTouch.h" typedef enum { - kGraphRange5Year = 0, - kGraphRange1Year, - kGraphRange3Month, + kGraphRange1Week = 0, kGraphRange1Month, - kGraphRange1Week, + kGraphRange3Month, + kGraphRange1Year, + kGraphRange5Year, kGraphRangeCount } JCStockGraphRange; @@ -38,12 +38,15 @@ typedef NSInteger JCStockGraphOptionMask; @property (nonatomic) JCStockGraphRange range; @property (nonatomic) CGPoint graphOffset; @property (nonatomic) CGSize graphSize; +@property (nonatomic) id parentPage; @property (strong, nonatomic) NSString *ticker; @property (strong, nonatomic) JCStockGraphView *graphView; -- (id)initWithTicker:(NSString *)ticker; +- (id)initWithTicker:(NSString *)ticker parent:(id)qParent; - (void)loadDataWithCompletion:(void (^)())completion; - (void)reloadGraph; +- (void)releaseGraph; + @end diff --git a/Classes/JCStockGraphController.m b/Classes/JCStockGraphController.m index 125ff5b..b179279 100755 --- a/Classes/JCStockGraphController.m +++ b/Classes/JCStockGraphController.m @@ -21,14 +21,14 @@ @interface JCStockGraphController () { NSArray *points; BOOL loaded; BOOL hasSetSize; - UITapGestureRecognizer *tapRecognizer; +// UITapGestureRecognizer *tapRecognizer; } @end @implementation JCStockGraphController -- (id)initWithTicker:(NSString *)ticker +- (id)initWithTicker:(NSString *)ticker parent:(id)qParent { self = [super init]; if (self) { @@ -37,6 +37,7 @@ - (id)initWithTicker:(NSString *)ticker self.range = kGraphRange5Year; self.graphOffset = CGPointZero; self.graphSize = CGSizeZero; + self.parentPage = qParent; } return self; } @@ -71,7 +72,7 @@ - (void)loadDataWithCompletion:(void (^)())completion dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - [[JCStockPriceStore sharedInstance] getDataForTicker:self.ticker withProgress:^(double progress) { + [[JCStockPriceStore sharedInstance] getDataForTicker:self.ticker parentPage:self.parentPage withProgress:^(double progress) { hud.progress = progress; } completion:^(NSArray *newPoints) { @@ -105,7 +106,7 @@ -(void)loadGraph (self.graphOptions & kGraphOptionHideYAxis) ? [self.graphView hideYAxis] : [self.graphView configureYAxisWithPoints:points]; if (!(self.graphOptions & kGraphOptionHideGrid)) [self.graphView configureGridLines]; if (!(self.graphOptions & kGraphOptionHideRangeLabel)) [self.graphView addRangeLabel]; - self.graphView.userInteractionEnabled = (self.graphOptions & kGraphOptionInteractive); + self.graphView.userInteractionEnabled = (BOOL) (self.graphOptions & kGraphOptionInteractive); [self.view addSubview:self.graphView]; } @@ -117,6 +118,12 @@ - (void)reloadGraph [self.graphView reloadGraph]; } +- (void)releaseGraph +{ + [self.graphView removePlots]; + self.graphView = nil; +} + - (NSArray *)thinPoints:(NSArray *)fullPoints { //Make graph look smoother by thinning out the number of data points diff --git a/Classes/JCStockGraphPageController.m b/Classes/JCStockGraphPageController.m index ad8b9eb..c7a451e 100755 --- a/Classes/JCStockGraphPageController.m +++ b/Classes/JCStockGraphPageController.m @@ -45,6 +45,19 @@ - (void)viewWillAppear:(BOOL)animated [self reloadViews]; } +- (void)viewDidDisappear:(BOOL)animated +{ + [super viewDidDisappear:animated]; + if (graphControllers!=nil) + { + for (JCStockGraphController *gc in graphControllers) + { + [gc releaseGraph]; + [gc removeFromParentViewController]; + } + } +} + - (void)reloadViews { if (pagingScrollView) { @@ -76,7 +89,7 @@ - (void)loadRemainingPages return; } - JCStockGraphController *graphController = [[JCStockGraphController alloc] initWithTicker:self.ticker]; + JCStockGraphController *graphController = [[JCStockGraphController alloc] initWithTicker:self.ticker parent:self]; //graphController.view.frame = self.view.bounds; graphController.graphOffset = self.graphOffset; graphController.graphSize = self.graphSize; diff --git a/Classes/JCStockGraphView.h b/Classes/JCStockGraphView.h index 916f951..65f227f 100755 --- a/Classes/JCStockGraphView.h +++ b/Classes/JCStockGraphView.h @@ -7,7 +7,8 @@ // #import -#import "CorePlot/CorePlot-CocoaTouch.h" +//#import "CorePlot/CorePlot-CocoaTouch.h" +#import "CorePlot-CocoaTouch.h" #import "JCStockGraphController.h" @class JCStockPriceStore; @@ -30,4 +31,6 @@ - (void)hideYAxis; - (void)addRangeLabel; +-(void)removePlots; + @end diff --git a/Classes/JCStockGraphView.m b/Classes/JCStockGraphView.m index 7b848e8..8859b8e 100755 --- a/Classes/JCStockGraphView.m +++ b/Classes/JCStockGraphView.m @@ -23,6 +23,21 @@ - (void)reloadGraph [self.hostView.hostedGraph reloadData]; } +#pragma mark - some release handle +-(void)removePlots +{ + for (CPTPlot* plot in [self.hostView.hostedGraph allPlots]) + { + plot.dataSource = nil; + plot.delegate = nil; + [plot deleteDataInIndexRange:NSMakeRange(0, plot.cachedDataCount)]; + [self.hostView.hostedGraph removePlot:plot]; + } + [self.hostView removeFromSuperview]; + self.hostView = nil; +} + + #pragma mark - Chart behavior -(void)configureHost @@ -83,7 +98,9 @@ -(void)configurePlotWithDataSource:(id)dataSource - (void)configureXAxisWithPoints:(NSArray *)points delegate:(id)delegate { // 0 - increase padding to make room for axis labels - self.hostView.hostedGraph.plotAreaFrame.paddingBottom = 24; + self.hostView.hostedGraph.plotAreaFrame.paddingBottom = 20; + self.hostView.hostedGraph.plotAreaFrame.paddingRight = 20; + self.hostView.hostedGraph.plotAreaFrame.paddingTop = 6; // 1 - Get axis set CPTXYAxisSet *axisSet = (CPTXYAxisSet *) self.hostView.hostedGraph.axisSet; @@ -115,6 +132,7 @@ - (void)configureYAxisWithPoints:(NSArray *)points priceFormatter.numberStyle = kCFNumberFormatterCurrencyStyle; priceFormatter.maximumSignificantDigits = 3; priceFormatter.usesSignificantDigits = YES; + priceFormatter.currencySymbol = @"$"; CPTXYAxis *y = axisSet.yAxis; y.axisConstraints = [CPTConstraints constraintWithLowerOffset:0]; @@ -194,7 +212,7 @@ - (void)addRangeLabel rangeLabel.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.4]; [rangeLabel sizeToFit]; rangeLabel.width += 8; - rangeLabel.y = self.height - rangeLabel.height; + rangeLabel.y = self.height + 4; // - rangeLabel.height; rangeLabel.right = self.right; rangeLabel.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleLeftMargin; [self addSubview:rangeLabel]; diff --git a/Classes/JCStockPriceStore.h b/Classes/JCStockPriceStore.h index c5259bc..4786c26 100755 --- a/Classes/JCStockPriceStore.h +++ b/Classes/JCStockPriceStore.h @@ -13,7 +13,7 @@ + (JCStockPriceStore *)sharedInstance; ///@return YES if we loaded data from the cache/memory, NO if we made a request for the data -- (BOOL)getDataForTicker:(NSString *)ticker withProgress:(void (^)(double progress))progBlock completion:(void (^)(NSArray *points))block; +- (BOOL)getDataForTicker:(NSString *)ticker parentPage:(id)qParent withProgress:(void (^)(double progress))progBlock completion:(void (^)(NSArray *points))block; @property (nonatomic) BOOL diskCachingEnabled; @property (nonatomic) BOOL memoryCachingEnabled; diff --git a/Classes/JCStockPriceStore.m b/Classes/JCStockPriceStore.m index 5ae2bd8..bfd0e9b 100755 --- a/Classes/JCStockPriceStore.m +++ b/Classes/JCStockPriceStore.m @@ -32,62 +32,76 @@ @implementation JCStockPriceStore + (JCStockPriceStore *)sharedInstance { if (!sharedInstance) { - sharedInstance = [[JCStockPriceStore alloc] init]; + sharedInstance =[[JCStockPriceStore alloc] init]; } return sharedInstance; } -- (BOOL)getDataForTicker:(NSString *)ticker withProgress:(void (^)(double progress))progBlock completion:(void (^)(NSArray *points))comp +- (void)mergePoints:(NSArray *)points todayPoints:(NSArray *)today_points completion:(void (^)(NSArray *points))comp { - NSAssert(ticker, @"tried to get historical data for null ticker"); - if (!ticker && comp) comp(nil); + if (!comp) return; + if (!points) return; - __block NSMutableArray *points = [[NSMutableArray alloc] init]; - - //Set time period: - NSDate *endDate = [NSDate date]; - NSDate *startDate = [endDate mt_dateYearsBefore:5]; - - //Check for previously cached data: - NSDictionary *cacheDict = [self loadCacheForTicker:ticker]; - if (cacheDict) { - //Found a cache; load it into our points array - [points addObjectsFromArray:cacheDict[@"data"]]; - NSDate *cacheDate = cacheDict[@"cacheDate"]; - if ([cacheDate mt_isWithinSameDay:endDate]) { - if (comp) comp(points); - return YES; - } else { - startDate = cacheDate; - } + NSMutableArray *newArray =[[NSMutableArray alloc] init]; + [newArray addObjectsFromArray:points]; + JCPriceDataPoint *point =[newArray lastObject]; + if (today_points &&[today_points count]>0) + { + JCPriceDataPoint *tPoint =[today_points objectAtIndex:0]; + if ([point.date isEqual:tPoint.date]==NO) + [newArray addObjectsFromArray:today_points]; } + comp(newArray); - //Build URL: - NSString *urlString = [NSString stringWithFormat:@"http://ichart.finance.yahoo.com/table.csv?s=%@&%@&%@", - ticker, [startDate yqlStartString], [endDate yqlEndString]]; - NSURL *url = [NSURL URLWithString:urlString]; +} + + +- (void)getTodayStockPrice:(NSString *)ticker longPoints:(NSArray *)points todayPoints:(NSArray *)today_points withProgress:(void (^)(double progress))progBlock completion:(void (^)(NSArray *points))comp +{ + // Request current price.. + // http://download.finance.yahoo.com/d/quotes.csv?s=AAPL&f=d1o0h0g0l1v0l1 + NSString *urlString =[NSString stringWithFormat:@"http://download.finance.yahoo.com/d/quotes.csv?s=%@&f=d1o0h0g0l1v0l1", ticker]; - //Create Request: - AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:[NSURLRequest requestWithURL:url]]; - AFHTTPResponseSerializer *serializer = [AFHTTPResponseSerializer serializer]; - serializer.acceptableContentTypes = [serializer.acceptableContentTypes setByAddingObject:@"text/csv"]; - operation.responseSerializer = serializer; - [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { + // escape for ^IXIC, ^INX + NSURL *url =[NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; + AFHTTPRequestOperation *operation2 =[[AFHTTPRequestOperation alloc] initWithRequest:[NSURLRequest requestWithURL:url]]; + [operation2 setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) + { + NSMutableArray *today_points =[[NSMutableArray alloc] init]; - NSString *csvString = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding]; - NSArray *newPoints = [self dataPointsForCSVString:csvString]; - [points addObjectsFromArray:newPoints]; + NSString *csvString =[[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding]; - if (comp) comp(points); + // reformat the date string + NSMutableString *csvString_tmp =[csvString mutableCopy]; + if ([csvString_tmp hasPrefix:@"Missing Symbols List"]) // 找不到代號的情形.. + { + [self mergePoints:points todayPoints:today_points completion:comp]; + return; + } - [self cachePoints:points forTicker:ticker]; + NSRegularExpression *regex =[NSRegularExpression regularExpressionWithPattern: @"\"([0-9]{1,2})/([0-9]{1,2})/([0-9]{4})\"" options:0 error:nil]; + [regex replaceMatchesInString:csvString_tmp options:0 range:NSMakeRange(0,[csvString_tmp length]) withTemplate:@"$3-$1-$2"]; + regex =[NSRegularExpression regularExpressionWithPattern: @"-([0-9]{1})-" options:0 error:nil]; + [regex replaceMatchesInString:csvString_tmp options:0 range:NSMakeRange(0,[csvString_tmp length]) withTemplate:@"-0$1-"]; + regex =[NSRegularExpression regularExpressionWithPattern: @"-([0-9]{1})$" options:0 error:nil]; + [regex replaceMatchesInString:csvString_tmp options:0 range:NSMakeRange(0,[csvString_tmp length]) withTemplate:@"-0$1"]; + csvString =[NSString stringWithFormat:@"FIRST_LINE_FOR_SKIPED\n%@", csvString_tmp]; + + + NSArray *newPoints =[self dataPointsForCSVString:csvString]; + [today_points addObjectsFromArray:newPoints]; + + + [self cachePoints:points todayPoints:today_points forTicker:ticker]; + [self mergePoints:points todayPoints:today_points completion:comp]; } failure:^(AFHTTPRequestOperation *operation, NSError *error) { - if (comp) comp(nil); + [self mergePoints:points todayPoints:today_points completion:comp]; NSLog(@"CSV request failure: %@", error); }]; - [operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) { + // Dowload Progress + [operation2 setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) { long long expected = totalBytesExpectedToRead; if (expected == -1) expected = 75000; //A bit more than average @@ -95,15 +109,118 @@ - (BOOL)getDataForTicker:(NSString *)ticker withProgress:(void (^)(double progre if (progBlock) progBlock(prog); }]; - [operation start]; + [operation2 start]; +} + +- (BOOL)getDataForTicker:(NSString *)ticker parentPage:(id)qParent withProgress:(void (^)(double progress))progBlock completion:(void (^)(NSArray *points))comp +{ + @synchronized (qParent) + { + NSAssert(ticker, @"tried to get historical data for null ticker"); + if (!ticker && comp) comp(nil); + + __block NSMutableArray *points =[[NSMutableArray alloc] init]; + __block NSMutableArray *today_points =[[NSMutableArray alloc] init]; + + //Set time period: + NSDate *endDate =[NSDate date]; + NSDate *startDate =[endDate mt_dateYearsBefore:5]; + + //Check for previously cached data: + BOOL needUpdateLong = NO; + BOOL needUpdateTotday = NO; + NSDictionary *cacheDict =[self loadCacheForTicker:ticker]; + if (cacheDict) { + //Found a cache; load it into our points array + [points addObjectsFromArray:cacheDict[@"data"]]; // long term data... + NSDate *cacheDate = cacheDict[@"cacheDate"]; + if (![cacheDate mt_isWithinSameDay:endDate] + ||[points count] < 50 // abnormal case.. + ) + { + needUpdateTotday = YES; + needUpdateLong = YES; + } else { + // check short term data.. + [today_points addObjectsFromArray:cacheDict[@"today_data"]]; + cacheDate = cacheDict[@"cacheTodayDate"]; + if ( + ![cacheDate mt_isWithinSameHour:endDate] + || ![cacheDate mt_isWithinSameDay:endDate] + ||[today_points count] > 1 + ) { + needUpdateTotday = YES; + } + } + } else { + needUpdateLong = YES; + needUpdateTotday = YES; + } + + + if (needUpdateLong) + { + //Build URL: + NSString *urlString =[NSString stringWithFormat:@"http://ichart.finance.yahoo.com/table.csv?s=%@&%@&%@", ticker,[startDate yqlStartString],[endDate yqlEndString]]; + + // escape characters, ex. ^IXIC, ^INX + NSURL *url =[NSURL URLWithString:[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; + + //Create Request: + AFHTTPRequestOperation *operation =[[AFHTTPRequestOperation alloc] initWithRequest:[NSURLRequest requestWithURL:url]]; + [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) + { + NSString *csvString =[[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding]; + NSArray *newPoints =[self dataPointsForCSVString:csvString]; + [points removeAllObjects]; + [points addObjectsFromArray:newPoints]; + + + [self getTodayStockPrice:ticker longPoints:points todayPoints:today_points withProgress:progBlock completion:comp]; + + } + failure:^(AFHTTPRequestOperation *operation, NSError *error) + { + // 201501. maybe TPO of Taiwan.. + if ([ticker hasSuffix:@".TW"]) + { + // change .TW to .TWO + NSString *qNewTicker = [NSString stringWithFormat:@"%@O", ticker]; + [self getDataForTicker:qNewTicker parentPage:qParent withProgress:progBlock completion:comp]; + } else { + // still try today stock price... + [self getTodayStockPrice:ticker longPoints:points todayPoints:today_points withProgress:progBlock completion:comp]; + NSLog(@"CSV request failure: %@", error); + } + }]; + + // Dowload Progress + [operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) { + long long expected = totalBytesExpectedToRead; + if (expected == -1) + expected = 75000; //A bit more than average + double prog = MIN((double) totalBytesRead / (double) expected, 1.0); + if (progBlock) progBlock(prog); + }]; + + [operation start]; + + } + else if (needUpdateTotday) { + [self getTodayStockPrice:ticker longPoints:points todayPoints:today_points withProgress:progBlock completion:comp]; + + } else { + [self mergePoints:points todayPoints:today_points completion:comp]; + } + } return NO; } - (NSArray *)dataPointsForCSVString:(NSString *)csvString { - NSArray *lines = [csvString componentsSeparatedByString:@"\n"]; - NSArray *columnNames = [lines[0] componentsSeparatedByString:@","]; - NSArray *data = [lines subarrayWithRange:NSMakeRange(1, [lines count]-2)]; + NSArray *lines =[csvString componentsSeparatedByString:@"\n"]; + NSArray *columnNames =[lines[0] componentsSeparatedByString:@","]; + NSArray *data =[lines subarrayWithRange:NSMakeRange(1,[lines count]-2)]; NSUInteger dateIndex = 0; NSUInteger closeIndex = 4; @@ -114,42 +231,47 @@ - (NSArray *)dataPointsForCSVString:(NSString *)csvString dateIndex = i; } - NSMutableArray *points = [[NSMutableArray alloc] initWithCapacity:data.count]; - NSNumberFormatter *nf = [[NSNumberFormatter alloc] init]; + NSMutableArray *points =[[NSMutableArray alloc] initWithCapacity:data.count]; + NSNumberFormatter *nf =[[NSNumberFormatter alloc] init]; + + data =[data sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)]; - for (NSString *rowString in [data reverseObjectEnumerator]) { + NSDate *lastDate=nil; + for (NSString *rowString in data) + { + NSArray *row =[rowString componentsSeparatedByString:@","]; + + JCPriceDataPoint *point =[[JCPriceDataPoint alloc] init]; + point.date =[NSDate mt_dateFromString:row[dateIndex] usingFormat:kDateFormatYahooAPI]; + if ([point.date isEqual:lastDate]) continue; - NSArray *row = [rowString componentsSeparatedByString:@","]; - - JCPriceDataPoint *point = [[JCPriceDataPoint alloc] init]; - point.date = [NSDate mt_dateFromString:row[dateIndex] usingFormat:kDateFormatYahooAPI]; - NSString *closeString = row[closeIndex]; - point.closePrice = [[nf numberFromString:closeString] doubleValue]; + point.closePrice =[[nf numberFromString:closeString] doubleValue]; [points addObject:point]; + + lastDate = point.date; } return points; } #pragma mark - Caching - - (NSString *)cachePathForTicker:(NSString *)ticker { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); - NSString *cacheDirectory = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"GraphData"]; + NSString *cacheDirectory =[[paths objectAtIndex:0] stringByAppendingPathComponent:@"GraphData"]; if (![[NSFileManager defaultManager] fileExistsAtPath:cacheDirectory]) [[NSFileManager defaultManager] createDirectoryAtPath:cacheDirectory withIntermediateDirectories:NO attributes:nil error:nil]; - return [cacheDirectory stringByAppendingPathComponent:ticker]; + return[cacheDirectory stringByAppendingPathComponent:ticker]; } - (NSDictionary *)loadCacheForTicker:(NSString *)ticker { NSDictionary *ret = inMemCache[ticker]; if (!ret && self.diskCachingEnabled) { - NSString *cachePath = [self cachePathForTicker:ticker]; + NSString *cachePath =[self cachePathForTicker:ticker]; @try { - ret = [NSKeyedUnarchiver unarchiveObjectWithFile:cachePath]; + ret =[NSKeyedUnarchiver unarchiveObjectWithFile:cachePath]; } @catch (...) { ret = nil; } @@ -157,32 +279,46 @@ - (NSDictionary *)loadCacheForTicker:(NSString *)ticker return ret; } -- (BOOL)cachePoints:(NSArray *)points forTicker:(NSString *)ticker +- (BOOL)cachePoints:(NSArray *)points todayPoints:(NSArray *)today_points forTicker:(NSString *)ticker { - NSDictionary *cacheDict = @{@"cacheDate": [NSDate date], @"data": points}; + NSDictionary *cacheDict = @{ + @"cacheDate":[NSDate date], @"data": points, @"cacheTodayDate":[NSDate date], @"today_data": today_points + }; inMemCache[ticker] = cacheDict; if (self.diskCachingEnabled) { - NSString *cachePath = [self cachePathForTicker:ticker]; - return [NSKeyedArchiver archiveRootObject:cacheDict toFile:cachePath]; + NSString *cachePath =[self cachePathForTicker:ticker]; + return[NSKeyedArchiver archiveRootObject:cacheDict toFile:cachePath]; } return NO; } +/*- (BOOL)cacheTodayPoints:(NSArray *)points forTicker:(NSString *)ticker + { + NSDictionary *cacheDict = @{@"cacheTodayDate": [NSDate date], @"today_data": points}; + inMemCache[ticker] = cacheDict; + + if (self.diskCachingEnabled) { + NSString *cachePath = [self cachePathForTicker:ticker]; + return [NSKeyedArchiver archiveRootObject:cacheDict toFile:cachePath]; + } + return NO; + } */ + - (void)setMemoryCachingEnabled:(BOOL)inMemoryCachingEnabled { inMemCache = nil; if (inMemoryCachingEnabled) - inMemCache = [[NSMutableDictionary alloc] init]; + inMemCache =[[NSMutableDictionary alloc] init]; } - (id)init { - self = [super init]; + self =[super init]; if (self) { self.memoryCachingEnabled = YES; self.diskCachingEnabled = YES; - inMemCache = [[NSMutableDictionary alloc] init]; + inMemCache =[[NSMutableDictionary alloc] init]; } return self; } diff --git a/Classes/MBProgressHUD+Customizations.h b/Classes/MBProgressHUD+Customizations.h index 29e3dd1..1ba5942 100755 --- a/Classes/MBProgressHUD+Customizations.h +++ b/Classes/MBProgressHUD+Customizations.h @@ -6,6 +6,9 @@ // Copyright (c) 2013 Benzinga. All rights reserved. // +#ifndef MBProgressHUD_Customizations_h +#define MBProgressHUD_Customizations_h + #import "MBProgressHUD.h" @interface MBProgressHUD (Cusomizations) @@ -17,3 +20,5 @@ - (UIView *)indicator; @end + +#endif \ No newline at end of file diff --git a/Classes/MHPagingScrollView.h b/Classes/MHPagingScrollView.h index 0b35eb1..04ee4e1 100755 --- a/Classes/MHPagingScrollView.h +++ b/Classes/MHPagingScrollView.h @@ -1,3 +1,5 @@ +#ifndef MHPagingScrollView_h +#define MHPagingScrollView_h @class MHPagingScrollView; @@ -79,3 +81,5 @@ - (void)didReceiveMemoryWarning; @end + +#endif \ No newline at end of file diff --git a/Classes/NSDate+YQL.h b/Classes/NSDate+YQL.h index 7850435..ec927a9 100644 --- a/Classes/NSDate+YQL.h +++ b/Classes/NSDate+YQL.h @@ -5,6 +5,8 @@ // Created by Joseph Constantakis on 5/4/14. // // +#ifndef NSDate_YQL_h +#define NSDate_YQL_h #import @@ -17,3 +19,5 @@ - (NSString *)yqlEndString; @end + +#endif \ No newline at end of file diff --git a/Classes/UIView+FrameAccessor.h b/Classes/UIView+FrameAccessor.h index 308b2a6..05f9824 100755 --- a/Classes/UIView+FrameAccessor.h +++ b/Classes/UIView+FrameAccessor.h @@ -5,6 +5,8 @@ // Created by Alex Denisov on 18.03.12. // Copyright (c) 2012 CoreInvader. All rights reserved. // +#ifndef UIView_FrameAccessor_h +#define UIView_FrameAccessor_h #import @@ -31,3 +33,5 @@ - (void)setRight:(CGFloat)newRight; @end + +#endif \ No newline at end of file diff --git a/Example/JCStockGraphExample/JCViewController.m b/Example/JCStockGraphExample/JCViewController.m index 2db2bf1..a37c99b 100644 --- a/Example/JCStockGraphExample/JCViewController.m +++ b/Example/JCStockGraphExample/JCViewController.m @@ -32,6 +32,17 @@ - (void)viewDidLoad self.graphPageController.shouldShowRotateHint = NO; [self.view addSubview:self.graphPageController.view]; + + // draw the same graph with axis and grid. + self.graphPageController = [[JCStockGraphPageController alloc] initWithTicker:@"AAPL"]; + self.graphPageController.view.frame = CGRectMake(0, 250, 320, 100); + self.graphPageController.graphOffset = CGPointMake(8, 0); + self.graphPageController.graphSize = CGSizeMake(290, 90); + self.graphPageController.graphOptions = kGraphOptionSmoothGraph /*| kGraphOptionHideXAxis | kGraphOptionHideGrid*/; + self.graphPageController.shouldAutoscroll = YES; + self.graphPageController.shouldShowRotateHint = NO; + + [self.view addSubview:self.graphPageController.view]; } @end diff --git a/JCStockGraph.podspec b/JCStockGraph.podspec index 245015e..c162d08 100644 --- a/JCStockGraph.podspec +++ b/JCStockGraph.podspec @@ -8,17 +8,17 @@ Pod::Spec.new do |s| s.author = { "Joseph Constantakis" => "jcon5294@gmail.com" } s.source = { :git => "https://github.com/jconst/JCStockGraph.git", :tag => s.version.to_s } - s.platform = :ios, '7.0' - s.ios.deployment_target = '7.0' + s.platform = :ios, '6.0' + s.ios.deployment_target = '6.0' s.requires_arc = true s.source_files = 'Classes' s.public_header_files = 'Classes/*.h' s.dependency 'CorePlot', '~> 1.5' - s.dependency 'AFNetworking', '~> 2.0' + s.dependency 'AFNetworking', '~> 1.3.0' s.dependency 'MBProgressHUD', '~> 0.8' - s.dependency 'MTDates', '~> 0.12' + s.dependency 'MTDates', '~> 0.13.0' s.dependency 'FontasticIcons', '~> 0.5' end