Я читаю файл .CSV
на сервере, используя NSMutableURLRequest
, и когда я выполнял анализ данных в формате CSV, я в итоге считал точки графика неполными.Например, если у меня есть 300 с лишним строк, приложение читает его из 150 с лишним строк.Любое предложение о том, как подойти к этому?Есть ли функция, которая хранит значения точек графика?Извините, я новичок в iOS.Большое спасибо за помощь
- (id) init
{
// regular [super init], etc. etc.
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:10.0 target:self selector:@selector(_connectionTimer:) userInfo:nil repeats:YES];
// other custom initialization continues
return self;
}
-(void)serverConnect{
NSMutableURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"URL/test.csv"] cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:15.0];
NSURLConnection *connection= [[NSURLConnection alloc] initWithRequest:request delegate:self];
}
- (void) _connectionTimer:(NSTimer *)timer {
[self serverConnect];
}
-(void)connection :(NSURLConnection *) connection didReceiveData:(NSData *)data{
response = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSString *stripped1 = [response stringByReplacingOccurrencesOfString:@"\r" withString:@""];
NSMutableArray *rows = [NSMutableArray arrayWithArray:[stripped1 componentsSeparatedByString:@"\n"]];
NSMutableArray *contentArray = [NSMutableArray arrayWithCapacity:[rows count]];
NSMutableArray *contentArray1 = [NSMutableArray arrayWithCapacity:[rows count]];
NSArray *components;
for (int i=0;i<[rows count]; i++) {
if(i == 0 || [[rows objectAtIndex:i] isEqualToString:@""]){
continue;
}
components = [[rows objectAtIndex:i] componentsSeparatedByString:@","];
id x = [components objectAtIndex:0] ;
id y = [components objectAtIndex:1];
id z = [components objectAtIndex:2];
[contentArray addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:x,@"X",y,@"Y", nil]];
[contentArray1 addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:x,@"X",z,@"Y", nil]];
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
[_graphHostingView setContentSize:CGSizeMake(2000, 1000)];
_graphHostingView.scrollEnabled = YES;
_graphHostingView.showsHorizontalScrollIndicator = YES;
_graphHostingView.showsVerticalScrollIndicator = YES;
[self init];
//[self serverConnect];
}
ответ переменной NSString
.Будет ли лучше, если я использую MSMutableString
или NSMutableArray
?Если нет, то кто-нибудь может объяснить, как метод -(NSArray *)numbersForPlot:(CPPlot *)plot field:(NSUInteger)fieldEnum recordIndexRange:(NSRange)indexRange;
помогает?Помогает ли мне сохранить данные сюжета?Итак, затем я могу просто загрузить его, когда основной график используется для построения?Влияет ли использование таймера на считываемые данные?