NSMutableData исчезает
в моей программе у меня есть переменная NSMutableData, которая собирает информацию изhttp://www.nhara.org/scored_races-2013.htm, Примерно в третий раз, когда он получает информацию с веб-сайта, когда он содержит 90810 байт, он либо исчезает, либо становится нулевым, потому что, если я печатаю его как строку NSString, он становится пустым. Вот код
- (void)viewWillAppear:(BOOL)animated
{
// Create a new data container for the stuff that comes back from the service
xmlData = [[NSMutableData alloc] initWithCapacity:180000];
[self fetchEntries];
[super viewWillAppear:animated];
}
- (void)fetchEntries
{
// Construct a URL that will ask the service for what you want
NSURL *url = [NSURL URLWithString: @"http://www.nhara.org/scored_races-2013.htm"];//
// Put that URL into an NSURLRequest
NSURLRequest *req = [NSURLRequest requestWithURL:url];
// Create a connection that will exchange this request for data from the URL
connection = [[NSURLConnection alloc] initWithRequest:req delegate:self startImmediately:YES];
}
- (void)connection:(NSURLConnection *)conn didReceiveData:(NSData *)data
{
// Add the incoming chunk of data to the container we are keeping
// The data always comes in the correct order
[xmlData appendData:data];
NSLog(@"%@",xmlData);
NSString *xmlCheck = [[[NSString alloc] initWithData:xmlData encoding:NSUTF8StringEncoding]autorelease];
NSLog(@"xmlCheck = %@", xmlCheck);
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
NSLog(@"error= %@",error);
}
- (void)connectionDidFinishLoading:(NSURLConnection *)conn {
// We are just checking to make sure we are getting the XML
NSString *xmlCheck = [[[NSString alloc] initWithData:xmlData encoding:NSUTF8StringEncoding] autorelease];
NSLog(@"xmlCheck2 = %@", xmlCheck);
}
Больше всего меня смущает то, что мой NSMutableData хранит данные, но затем теряет их, утверждая, что имеет такое же количество байтов.
Есть ли ограничение на размер NSMutableData или моя проблема только в управлении памятью?