views:

41

answers:

0

Hi, i am working on a sample ebook app and using nsurlconnection for downloading ebook file from net.

enter code here- (void) start
  {
if (![self isCancelled])
{
    NSLog(@"baslad");
    connection_ = [[NSURLConnection connectionWithRequest:[NSURLRequest requestWithURL: download_.url] delegate: self] retain];
    if (connection_ != nil) {

        [self willChangeValueForKey:@"isExecuting"];
        executing_ = YES;
        [self didChangeValueForKey:@"isExecuting"];

    } else {

        [self willChangeValueForKey:@"isExecuting"];
        finished_ = YES;
        [self didChangeValueForKey:@"isExecuting"];
    }
}
else
{
    // If it's already been cancelled, mark the operation as finished.
    [self willChangeValueForKey:@"isFinished"];
    {
        finished_ = YES;
    }
    [self didChangeValueForKey:@"isFinished"];
}}

 - (void) connection: (NSURLConnection*) connection didReceiveData: (NSData*) data
  {

[data_ appendData: data]; 

download_.progress = ((float) [data_ length] / (float) download_.size);

[delegate_ downloadOperationDidMakeProgress: self];

   }
   - (void)connection: (NSURLConnection*) connection didReceiveResponse: (NSHTTPURLResponse*) response
 {
statusCode_ = [response statusCode];

if (statusCode_ == 200) {
    download_.size = [response expectedContentLength];
}
NSLog(@"downok");}

with this code i am able to download files from web. but this code work with ipad simulator only. when i tried with iphone simulator or iphone device downloads dont start. and i cant recieve any error messages.

i think this is weird. why codes works with ipad simulator only? any idea? Thanks for helps. sorry for my english.