Skip to content

Commit 68d79ab

Browse files
authored
Enable ARC on Apple (#4)
Signed-off-by: Darshan Sen <raisinten@gmail.com>
1 parent 861006a commit 68d79ab

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/apple/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
add_library(benoni STATIC http.mm)
22

3+
target_compile_options(benoni PUBLIC "-fobjc-arc")
4+
35
target_include_directories(benoni PUBLIC "${PROJECT_SOURCE_DIR}/include")
46

57
target_link_libraries(benoni PUBLIC "-framework Foundation")

src/apple/http.mm

+5-6
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ - (BenoniHTTPTaskContextWrap *)initWithContext:
3939

4040
- (void)dealloc {
4141
delete context;
42-
[super dealloc];
4342
}
4443
@end
4544

@@ -123,7 +122,7 @@ - (void)URLSession:(NSURLSession *)session
123122
HTTPTaskContext *context = [contextWrap context];
124123

125124
if (context->data == nil) {
126-
context->data = [[NSMutableData data] retain];
125+
context->data = [NSMutableData data];
127126
}
128127

129128
[context->data appendData:data];
@@ -140,7 +139,7 @@ - (void)URLSession:(NSURLSession *)session
140139

141140
if (error) {
142141
std::string error_string([[error localizedDescription] UTF8String]);
143-
[contextWrap dealloc];
142+
contextMap_[key] = nil;
144143
callback(std::move(error_string));
145144
return;
146145
}
@@ -159,11 +158,11 @@ - (void)URLSession:(NSURLSession *)session
159158
}
160159
[responseString appendString:chunk];
161160
}];
162-
[context->data release];
161+
context->data = nil;
163162

164163
if (success == NO) {
165164
std::string error_string("response body has invalid encoding");
166-
[contextWrap dealloc];
165+
contextMap_[key] = nil;
167166
callback(std::move(error_string));
168167
return;
169168
}
@@ -175,7 +174,7 @@ - (void)URLSession:(NSURLSession *)session
175174
.status = context->status,
176175
.headers = std::move(context->headers),
177176
};
178-
[contextWrap dealloc];
177+
contextMap_[key] = nil;
179178
callback(response);
180179
}
181180
@end

0 commit comments

Comments
 (0)