cocoa_common: replace class/instance dot-syntax with bracket calls

GCC 4.0 (Xcode 3.1, PowerPC) reports:

    cocoa_common.m:1059: error: syntax error before '.' token
    cocoa_common.m:1074: error: syntax error before '.' token

Lines 1059 and 1074 use Objective-C class-method dot-syntax:

    NSUserDefaults.standardUserDefaults

Class dot-syntax is a newer Obj-C 2.0 feature (Xcode 4.4+, 2012) that
GCC 4.0 doesn't support at all.  The compiler tries to parse the
class name as an identifier, then stumbles on '.' because it isn't
a C struct.

Line 1062 has the companion issue: backup.UTF8String is instance
dot-syntax on -UTF8String, which on 10.5 is declared as a plain
method, not @property.  Apple GCC 4.0 supports instance dot-syntax
only for declared @property — same class of issue as the earlier
cocoa-dot-syntax fixes in c49a525, d38dcb5.

Convert all three sites to bracket syntax:

  [NSUserDefaults.standardUserDefaults foo]
    -> [[NSUserDefaults standardUserDefaults] foo]
  backup.UTF8String
    -> [backup UTF8String]

Also preemptively fix an identical case at line 845 in
cocoa_screen_get_chosen (screens.count -> [screens count]) which
sits in OSX-reachable code and would fail next.

Modern clang compiles both forms identically.  Zero runtime change.
This commit is contained in:
U-DESKTOP-SPFP6AQ\twistedtechre committed 2026-04-21 02:33:22 +02:00
1 parent 26590dd3c5
commit f4d1390a19
1 file changed
+4 -4
+4 -4
View File
@@ -842,7 +842,7 @@ void *cocoa_screen_get_chosen(void)
monitor_index = settings->uints.video_monitor_index;
if (monitor_index >= screens.count)
if (monitor_index >= [screens count])
return (BRIDGE void*)screens;
return ((BRIDGE void*)[screens objectAtIndex:monitor_index]);
}
@@ -1056,10 +1056,10 @@ bool cocoa_get_metrics(
config_file_t *open_userdefaults_config_file(void)
{
config_file_t *conf = NULL;
NSString *backup = [NSUserDefaults.standardUserDefaults stringForKey:@FILE_PATH_MAIN_CONFIG];
NSString *backup = [[NSUserDefaults standardUserDefaults] stringForKey:@FILE_PATH_MAIN_CONFIG];
if ([backup length] > 0)
{
conf = config_file_new_from_string(backup.UTF8String, path_get(RARCH_PATH_CONFIG));
conf = config_file_new_from_string([backup UTF8String], path_get(RARCH_PATH_CONFIG));
config_set_int(conf, "bundle_assets_extract_last_version", 0);
}
return conf;
@@ -1071,7 +1071,7 @@ void write_userdefaults_config_file(void)
encoding:NSUTF8StringEncoding
error:nil];
if (conf)
[NSUserDefaults.standardUserDefaults setObject:conf forKey:@FILE_PATH_MAIN_CONFIG];
[[NSUserDefaults standardUserDefaults] setObject:conf forKey:@FILE_PATH_MAIN_CONFIG];
}
#if TARGET_OS_TV