swift - Cannot convert value of type 'NSRange'(aka'_NSRange') to expected argument type 'Range<Data.Index>' (aka 'Range<int> -


there. beginner in swift , trying convert older program swift3. i´ve managed fix bunch of errors, cannot function work.

fileprivate func extractentitlements(_ entitlementdata: data) -> nsdictionary? {   var originalentitlementsdata = entitlementdata   let xmlstart = "<?xml".data(using: string.encoding.ascii, allowlossyconversion: true)   let bytes = (originalentitlementsdata nsdata).bytes   in 0...(originalentitlementsdata.count - xmlstart!.count) {      if memcmp((xmlstart! nsdata).bytes, bytes + i, int(xmlstart!.count)) == 0 {         let end = originalentitlementsdata.count -         **originalentitlementsdata = originalentitlementsdata.subdata(in: nsmakerange(i, end))**         break;      }   }    return nsstring(data: originalentitlementsdata, encoding: string.encoding.ascii.rawvalue)?.propertylist() as? nsdictionary 

}

here error get:

cannot convert value of type 'nsrange'(aka'_nsrange') expected argument type 'range<data.index>' (aka 'range<int>')

there bunch of questions regarding error, not being successful implementing solution. tips on how should proceed?

thanks guys!

ranges more complicated , simpler @ same time in swift.

you want subdata(in: start..<end), makes range<int>, type need. however, in case start , end refer beginning , end indexes of range, not location , length pass nsmakerange().


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -