Hi Guys
i am trying to use progressbar while downloading using NSUrlConnection
am missing somthing but dont know what
see my code
in my .h i have
NSMutableData *receivedData;
NSNumber *FileSize;
which i use to calculate a precent for progressbar
in my .m
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
[receivedData setLength:0];
FileSize = [NSNumber numberWithLongLong:[response expectedContentLength]];
}
and
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[receivedData appendData:data];
NSNumber *resourceLength = [NSNumber numberWithUnsignedInteger:[receivedData length]];
NSLog(@"resourceData length: %d ", [resourceLength intValue]);
NSNumber *progress = [NSNumber numberWithFloat:([resourceLength floatValue] / [FileSize floatValue])];
updateProgressBar.progress = [progress floatValue];
}
When its reach the line with FileSize float its crash
2010-10-05 22:32:19.924 Quran[2067:207] resourceData length: 1090 Program received signal: “EXC_BAD_ACCESS”.