Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions plugins/gamecenter/game_center.mm
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
GodotIntArray maximum_points;
Array hidden;
Array replayable;
GodotFloatArray rarity_percents;

for (NSUInteger i = 0; i < [descriptions count]; i++) {

Expand All @@ -226,6 +227,14 @@
hidden.push_back(description.hidden == YES);

replayable.push_back(description.replayable == YES);

NSNumber *number;
#ifdef __IPHONE_17_0
if (@available(iOS 17.0, *)) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need both the macro and the availability checks, the former to allow building on pre-17.0 SDKs and the latter to silence compilation warnings when building on >17.0.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like this will probably work without ifdefs (property should have default getter with the same name):

if ([description respondsToSelector:@selector(rarityPercent)]) {
	number = [description performSelector:@selector(rarityPercent)];
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better, great suggestion! I confirmed this works with iOS 17.

number = description.rarityPercent;
}
#endif
rarity_percents.push_back(number != NULL ? number.doubleValue : -1);
}

ret["names"] = names;
Expand All @@ -235,6 +244,7 @@
ret["maximum_points"] = maximum_points;
ret["hidden"] = hidden;
ret["replayable"] = replayable;
ret["rarity_percents"] = rarity_percents;

} else {
ret["result"] = "error";
Expand Down