Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Reading large files from NSInputstream is not working in ios

    • 0
    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 1.95k
    Answer it

    I am trying to read large Image file more than 300KB from NSInputStream. But i'm getting only upto 300KB. Other data are missing. Could you please help me if you know. i'm waiting for your valuable answer. I mentioned my code below : Call this readAllData method from NSStreamEventsHasBytesAvailable:

    - (void)readAllData {
    
    if ( _readData == nil) {
    _readData = [[NSMutableData data] retain];
    }
    
    while ([[ _session inputStream] hasBytesAvailable])
    {
    unsigned   int bytesRead = 0;
    bytesRead = [[ _session inputStream] read:buf maxLength: @"1024"];
    
    if (bytesRead) {
    
        NSMutableString * _string = [NSMutableString stringWithString:@""];
        for (int i = 0; i < _readData.length; i++) {
            unsigned char _byte;
            [&#95;readData getBytes:&&#95;byte range:NSMakeRange(i, 1)];
            i f ( _byte >= 32 && _byte < 127) {
                [ _string appendFormat:@"%c", _byte];
            } else {
                [ _string appendFormat:@"[%d]", _byte];
            }
        }
    
        [ _readData appendBytes:(const void *)buf length:bytesRead];
    
    }
    
    }
    
      NSString *string=[NSString stringWithFormat:@"%d", _readData.length];
     UIAlertView *sesView = [[UIAlertView alloc] initWithTitle:@"readDatalength"
                                                  message:string
                                                 delegate:self
                                        cancelButtonTitle:nil otherButtonTitles:@"OK"  , nil];
     [sesView show];
      }
    

 1 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: