diff --git a/CMakeLists.txt b/CMakeLists.txt index 46a1ed41ca..3676e88ab8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -289,6 +289,11 @@ if (APPLE OR CMAKE_SYSTEM MATCHES "Linux") list(APPEND LIBNANOGUI_PYTHON_EXTRA_SOURCE ext/coro/coro.c) endif() +if (APPLE) + # Use automatic reference counting for Objective-C portions + add_compile_options(-fobjc-arc) +endif() + add_definitions(${NANOGUI_EXTRA_DEFS}) # Compile main NanoGUI library diff --git a/src/darwin.mm b/src/darwin.mm index 96da2d7b4b..1541f12002 100644 --- a/src/darwin.mm +++ b/src/darwin.mm @@ -6,7 +6,7 @@ std::string file_dialog(const std::vector> &filetypes, bool save) { std::string path = ""; if (save) { - NSSavePanel *saveDlg = [[NSSavePanel savePanel] retain]; + NSSavePanel *saveDlg = [NSSavePanel savePanel]; NSMutableArray *types = [NSMutableArray new]; for (size_t idx = 0; idx < filetypes.size(); ++idx) @@ -17,7 +17,7 @@ if ([saveDlg runModal] == NSModalResponseOK) path = [[[saveDlg URL] path] UTF8String]; } else { - NSOpenPanel *openDlg = [[NSOpenPanel openPanel] retain]; + NSOpenPanel *openDlg = [NSOpenPanel openPanel]; [openDlg setCanChooseFiles:YES]; [openDlg setCanChooseDirectories:NO];