Reputation: 47
I try to create an NSRange object in Objective-C on my Mac. Unfortunately it gives me an error message which I cannot solve or debug.
NSRange newRange = [data rangeOfData:dataToFind
options:kNilOptions
range:NSMakeRange(0u, [newData length])];
The error message I get is:
*** -[NSConcreteData rangeOfData:options:range:]: range {0, 81701012} exceeds data length 347124
The size of dataToFind is : 57854 The size of newData is : 81701012
The max. size of the NSRange length is by default an NSUInteger : 18446744073709551615
so what is the error message about? Where do the 347124 come from?
Upvotes: 2
Views: 265
Reputation: 122391
You are referencing data
but using the length of newData
:
NSRange newRange = [data rangeOfData:dataToFind
options:kNilOptions
range:NSMakeRange(0u, [newData length])];
That doesn't look right.
Upvotes: 2
Reputation: 20993
You are searching in data
yet you provide the range to search starting from zero of the length newData.length
. Apparently newData
is longer than data
. Change to NSMakeRange(0u, [data length])
.
Upvotes: 2