Skip to content

Commit f4d1390

Browse files
committed
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.
1 parent 26590dd commit f4d1390

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

ui/drivers/cocoa/cocoa_common.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ void osx_show_file_sheet(void)
842842

843843
monitor_index = settings->uints.video_monitor_index;
844844

845-
if (monitor_index >= screens.count)
845+
if (monitor_index >= [screens count])
846846
return (BRIDGE void*)screens;
847847
return ((BRIDGE void*)[screens objectAtIndex:monitor_index]);
848848
}
@@ -1056,10 +1056,10 @@ bool cocoa_get_metrics(
10561056
config_file_t *open_userdefaults_config_file(void)
10571057
{
10581058
config_file_t *conf = NULL;
1059-
NSString *backup = [NSUserDefaults.standardUserDefaults stringForKey:@FILE_PATH_MAIN_CONFIG];
1059+
NSString *backup = [[NSUserDefaults standardUserDefaults] stringForKey:@FILE_PATH_MAIN_CONFIG];
10601060
if ([backup length] > 0)
10611061
{
1062-
conf = config_file_new_from_string(backup.UTF8String, path_get(RARCH_PATH_CONFIG));
1062+
conf = config_file_new_from_string([backup UTF8String], path_get(RARCH_PATH_CONFIG));
10631063
config_set_int(conf, "bundle_assets_extract_last_version", 0);
10641064
}
10651065
return conf;
@@ -1071,7 +1071,7 @@ void write_userdefaults_config_file(void)
10711071
encoding:NSUTF8StringEncoding
10721072
error:nil];
10731073
if (conf)
1074-
[NSUserDefaults.standardUserDefaults setObject:conf forKey:@FILE_PATH_MAIN_CONFIG];
1074+
[[NSUserDefaults standardUserDefaults] setObject:conf forKey:@FILE_PATH_MAIN_CONFIG];
10751075
}
10761076

10771077
#if TARGET_OS_TV

0 commit comments

Comments
 (0)