aboutsummaryrefslogtreecommitdiff
path: root/osx.m
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2015-09-18 12:20:32 +0100
committerSimon Tatham <anakin@pobox.com>2015-09-18 12:20:32 +0100
commitba9e0d586ec8d2662d7ff6065797c6ef327623a7 (patch)
tree7f62b63aab4010617ac5e4c65bf258f23cc30c14 /osx.m
parenteda5a867872e718b62ea52373ec9f44aa0c3bda2 (diff)
downloadpuzzles-ba9e0d586ec8d2662d7ff6065797c6ef327623a7.zip
puzzles-ba9e0d586ec8d2662d7ff6065797c6ef327623a7.tar.gz
puzzles-ba9e0d586ec8d2662d7ff6065797c6ef327623a7.tar.bz2
puzzles-ba9e0d586ec8d2662d7ff6065797c6ef327623a7.tar.xz
Fix OS X build failure due to a deprecated method.
Apple upgraded me to Xcode 7 yesterday, and now [NSString cString] gives a deprecation warning, which -Werror turns into a full-on build failure. Explicitly specify an encoding. (I mention in a comment that there's an alternative piece of API that I possibly ought to be using instead, but until I make a concrete decision about where my backwards compatibility threshold is, I'll leave it as it is for the moment.)
Diffstat (limited to 'osx.m')
-rw-r--r--osx.m19
1 files changed, 18 insertions, 1 deletions
diff --git a/osx.m b/osx.m
index 13abc4e..7a8bdeb 100644
--- a/osx.m
+++ b/osx.m
@@ -761,7 +761,24 @@ struct frontend {
[op setAllowsMultipleSelection:NO];
if ([op runModalForTypes:nil] == NSOKButton) {
- const char *name = [[[op filenames] objectAtIndex:0] cString];
+ /*
+ * This used to be
+ *
+ * [[[op filenames] objectAtIndex:0] cString]
+ *
+ * but the plain cString method became deprecated and Xcode 7
+ * started complaining about it. Since OS X 10.9 we can
+ * apparently use the more modern API
+ *
+ * [[[op URLs] objectAtIndex:0] fileSystemRepresentation]
+ *
+ * but the alternative below still compiles with Xcode 7 and
+ * is a bit more backwards compatible, so I'll try it for the
+ * moment.
+ */
+ const char *name = [[[op filenames] objectAtIndex:0]
+ cStringUsingEncoding:
+ [NSString defaultCStringEncoding]];
char *err;
FILE *fp = fopen(name, "r");