iphone - Reading large files from NSInputstream is not working in ios -


i trying read large image file more 300kb nsinputstream. i'm getting upto 300kb. other data missing. please me if know. i'm waiting valuable answer. mentioned code below : call readalldata method nsstreameventshasbytesavailable:

    - (void)readalldata {      if (_readdata == nil) {     _readdata = [[nsmutabledata data] retain];     }      while ([[_session inputstream] hasbytesavailable])     {     unsigned   int bytesread = 0;     bytesread = [[_session inputstream] read:buf maxlength:ead_input_buffer_size];      if (bytesread) {          nsmutablestring *_string = [nsmutablestring stringwithstring:@""];         (int = 0; < _readdata.length; i++) {             unsigned char _byte;             [_readdata getbytes:&_byte range:nsmakerange(i, 1)];             if (_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]; 

}

when method hasbytesavailable returns no doesn't mean, nsinputstream empty. nsinputstream @ end when status nsstreamstatusatend. example stream been built nsurl asynchronous , has no bytes after opening. if case should subscribe nsinputstream declaring class nsstreamdelegate.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -