我正面临崩溃“因未捕获的异常NSRangeException
而终止应用”,原因是:
' * - [NSSubrangeData subdataWithRange:]:范围{8,565316237}超出 数据长度210204'“
如果有人可以帮助我找到解决方案。
-(NSData *) parseAtom:(MP4Atom **) pAtom fromData:(NSData *) data {
// Assume it all remains
NSData *remainingData = data;
// Data must not be nil
if( data != nil ) {
// Length must be at least 8 bytes
if( data.length > 8 ) {
// Read type and size
UInt32 size = [data uint32AtOffset:0];
NSString *type = [data fourByteStringAtOffset:4];
// The rest is data
NSData *atomData = [data subdataWithRange:NSMakeRange(8, size - 8)];
// Read the atom
MP4Atom *atom = [MP4Atom mp4AtomWithType: type data:atomData];
// Get the remaining data
if( size < data.length) {
remainingData = [data subdataWithRange:NSMakeRange(size, data.length - size)];
} else {
remainingData = nil;
}
// If we got a valid result...
if( atom != nil ) {
// ... and pAtom was not nil,
if( pAtom != nil ) {
// assign the atom
*pAtom = atom;
} else {
DDLogCritical( @"pAtom is nil in parseAtom:fromData:");
}
} else {
DDLogCritical( @"Failed to parse atom from data in parseAtom:fromData:");
}
} else {
DDLogCritical( @"data is too short (%d) expected at least 8 bytes in parseAtom:fromData:", data.length);
}
} else {
DDLogCritical( @"data is nil in parseAtom:fromData:");
}
return remainingData;
}