3

I am using the [NSKeyedUnarchiver unarchiveObjectWithData:result] methode for unarchiving NSData in my objective c bases app.

NSMutableArray *array = (NSMutableArray *)[NSKeyedUnarchiver unarchiveObjectWithData:result];

This is working pretty fine upto iOS15. But since iOS16 I am getting a crash that [MyClass initWithCoder:]: unrecognized selector sent to instance 0x281069760.

In iOS16 code is working fine when I am using an array of NSDictionary or any system types like NSString. But I am adding my own custom class objects to the array and it makes the issue. (More intersting fact is that issue is only in real devices, not in simulators.)

I can see that unarchiveObjectWithData methos is depricated. So as suggested in xcode, now I have tried

NSError *err;
@try {
    NSMutableArray *array = (NSMutableArray *)[NSKeyedUnarchiver unarchivedObjectOfClass:[NSMutableArray class] fromData:result error:&err];
 }
 @catch (NSException *exception) {
    NSLog(@"Exception %@", exception.reason);
 }

Now I am getting nil value for my array and the err is err = 0x0000000281ff1020 domain: nil - code: 4864

There were no issues before I updated my iPad to iPadOS 16. Any help is appreciated.

I have added the source code for this issue in this repo

  • Does this help you? https://stackoverflow.com/questions/58043107/how-to-update-nskeyedunarchiver-unarchiveobjectwithdata-to-nskeyedunarchiver-una – vadian Nov 08 '22 at 11:18

0 Answers0