From 7360e6dae6bad03df0973f20c5e5b71c44a3e745 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Sat, 25 Oct 2025 10:28:28 +0200 Subject: [PATCH 15/48] correcting #endif comment, add for loop macro for obj-c versions --- include/wx/defs.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/include/wx/defs.h b/include/wx/defs.h index 73e89b5930..7831720cd9 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -2851,7 +2851,27 @@ typedef WX_UIPasteboard WXOSXPasteboard; #endif -#endif /* __WXMAC__ */ +// Define a for loop macro to iterate over Objective-C collections that works also for +// compilers like gcc that does not support the "for .. in" syntax. + +#if OBJC_API_VERSION >= 2 + + #define wxOBJC_FOR_LOOP(var, collection) \ + for (var in collection) \ + { + +#else + + #define wxOBJC_FOR_LOOP(var, collection) \ + for (NSUInteger wx_i = 0; wx_i < [collection count]; wx_i++) \ + { var = [collection objectAtIndex:wx_i]; + +#endif + +#define wxOBJC_END_FOR_LOOP \ + } + +#endif /* __DARWIN__ */ /* ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port */ #if defined(__WIN32__) -- 2.24.3 (Apple Git-128)