Post

Replies

Boosts

Views

Activity

The app will crash on IOS 18 when send a network request
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; configuration.URLCache = [[NSURLCache alloc] initWithMemoryCapacity:20 * 1024 * 1024 diskCapacity:100 * 1024 * 1024 diskPath:@"myCache"]; if (!configuration) { NSLog(@"Failed to create session configuration."); return; } NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration]; if (!session) { NSLog(@"Failed to create session."); return; } NSURL *url = [NSURL URLWithString:@"https://example.com"]; if (!url) { NSLog(@"Invalid URL."); return; } NSURLRequest *request = [NSURLRequest requestWithURL:url]; if (!request) { NSLog(@"Failed to create request."); return; } NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { if (error) { NSLog(@"Error: %@", error.localizedDescription); } else { NSLog(@"Data received: %@", data); } }]; if (!dataTask) { NSLog(@"Failed to create data task."); return; } dataTask.priority = NSURLSessionTaskPriorityDefault; [dataTask resume]; error message Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSFileManager createDirectoryAtURL:withIntermediateDirectories:attributes:error:]: URL is nil' *** First throw call stack: (0x1848bd08c 0x181bbf2e4 0x183585f48 0x185d2f2bc 0x185d2ec7c 0x10709271c 0x1070a3f04 0x185d2ea88 0x185d2db20 0x185d2d5f4 0x185d2d07c 0x185d274b0 0x185dd82c4 0x185dd8214 0x185dd730c 0x107090a30 0x10709271c 0x10709a5e8 0x10709b394 0x10709cb20 0x1070a85f0 0x1070a7c00 0x20bc27c7c 0x20bc24488) libc++abi: terminating due to uncaught exception of type NSException
4
0
652
Sep ’24