An uncaught exception
'NSInvalidArgumentException', reason: '*\ setObjectForKey: object cannot be nil
occasionally happen in MKNetworkEngine.m at line 619:
(self.memoryCache)[cacheDataKey] = data;
In my case in the console usually come with:
: Max open files: 78
A bit of research shows that there exists a number of opened file limitation on iOS
Further investigation locates the cause as follow:
In MKNetworkEngine.m method cachedDataForOperation:(MKNetworkOperation*) operation:
```
if([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
cachedData = [NSData dataWithContentsOfFile:filePath];
[self saveCacheData:cachedData forKey:[operation uniqueIdentifier]]; // bring it back to the in-memory cache
return cachedData;
}
```
line 394 can return cachedData with nil value
Adding a simple if-condition check can avoid the problem.
An uncaught exception 'NSInvalidArgumentException', reason: '*\ setObjectForKey: object cannot be nil occasionally happen in MKNetworkEngine.m at line 619: (self.memoryCache)[cacheDataKey] = data;
In my case in the console usually come with: