ObjC for loop to pascal lazarus / 33-macOS - Mac OS X ---------------------------------------------------------------------- rossh_lz · 2022-02-17 08:04 How to write a Pascal version of this style of c loop? for (NSString *key in dictionary) {   // do something with key } // dictionary is an  objcclass  NSDictionary Thanks ---------------------------------------------------------------------- Zvoni · 2022-02-17 09:50 at a guess: TStringList or TFPGMap as a Dictionary ---------------------------------------------------------------------- trev · 2022-02-17 11:13 Here's an example from something I wrote ages ago: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ...     myDictionary : NSDictionary;     i  : Byte = 0;  ...     myDictionary := NSProcessInfo.ProcessInfo.environment;     for i := 0 to (myDictionary.count - 1) do       begin         Form1.Memo1.Lines.Add('Env Var: '           + myDictionary.allKeys.objectAtIndex(i).UTF8String           + ' = '         + myDictionary.allValues.objectAtIndex(i).UTF8String         );       end; Outputs: QuoteEnv Var: COMMAND_MODE = unix2003 Env Var: PATH = /usr/bin:/bin:/usr/sbin:/sbin Env Var: TMPDIR = /var/folders/t3/f0rslzrn70qb61l12j31c5sr0000gn/T/ Env Var: __CFBundleIdentifier = com.company.project1 Env Var: LOGNAME = trev Env Var: HOME = /Users/trev Env Var: XPC_FLAGS = 0x0 Env Var: DISPLAY = /private/tmp/com.apple.launchd.e7IspcKmOY/org.xquartz:0 Env Var: SSH_AUTH_SOCK = /private/tmp/com.apple.launchd.0xEkRTg8Fg/Listeners Env Var: USER = trev Env Var: XPC_SERVICE_NAME = application.com.company.project1.783302.10524195 Env Var: SHELL = /bin/tcsh Env Var: __CF_USER_TEXT_ENCODING = 0x1F5:0x0:0xF Full example in my Wiki article:  Accessing macOS System Information. ---------------------------------------------------------------------- Jonas Maebe · 2022-02-17 20:28 FPC supports the so-called Objective-C fast enumeration using the Pascal "for x in y do" construct. See https://wiki.freepascal.org/FPC_PasCocoa#Fast_enumeration (you do need to activate the objectivec2 modeswitch)