Skip to content

Commit 7bb92cf

Browse files
nstring: NSString support on macOS
1 parent b74942a commit 7bb92cf

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

dub.sdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ buildOptions "debugInfoC" platform="windows"
1111
// Enable Objective-C integration on apple platforms.
1212
configuration "appleos" {
1313
platforms "osx" "ios" "watchos" "tvos" "visionos"
14-
1514
targetType "library"
15+
1616
dependency "objective-d" version="~>1.0" optional=true default=false
1717
}
1818

source/numem/string.d

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,25 @@ public:
157157
}
158158
}
159159

160-
/**
161-
Creates a string from an Objective-C NSString.
162-
163-
This will release 1 reference from the NSString.
164-
*/
165160
version(Have_objective_d)
166-
this(NSString str) {
167-
this.set_(str.toString());
168-
str.release();
161+
static if (is(T == char)) {
162+
163+
/**
164+
Creates a string from an Objective-C NSString.
165+
166+
This will release 1 reference from the NSString.
167+
*/
168+
this(NSString str) {
169+
this.set_(str.toString());
170+
str.release();
171+
}
172+
173+
/**
174+
To Objective-C NSString
175+
*/
176+
NSString toNSString() {
177+
return NSString.create(ptr);
178+
}
169179
}
170180

171181
/**
@@ -312,14 +322,6 @@ public:
312322
*/
313323
alias toString = toDString;
314324

315-
/**
316-
To Objective-C NSString
317-
*/
318-
version(Have_objective_d)
319-
NSString toNSString() {
320-
return NSString.create(ptr);
321-
}
322-
323325
/**
324326
Set content of string
325327
*/

0 commit comments

Comments
 (0)