Skip to content

[cupertino_http] Update to package:objective_c 8.0 #1802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions pkgs/cupertino_http/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* Add the ability to abort requests.
* Make `ConnectionException.toString` more helpful.
* Upgrade to `package:objective_c` 8.0.

## 2.2.0

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void testOnData(URLSessionConfiguration Function() config) {
onData: (s, t, d) {
actualSession = s;
actualTask = t;
actualData.appendData_(d);
actualData.appendData(d);
});

final task = session.dataTaskWithRequest(
Expand Down
22 changes: 11 additions & 11 deletions pkgs/cupertino_http/example/integration_test/utils_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,31 @@ void main() {

test('single string input', () {
final d = objc.NSMutableDictionary()
..setObject_forKey_('value'.toNSString(), 'key'.toNSString());
..setObject('value'.toNSString(), forKey: 'key'.toNSString());

expect(stringNSDictionaryToMap(d), {'key': 'value'});
});

test('multiple string input', () {
final d = objc.NSMutableDictionary()
..setObject_forKey_('value1'.toNSString(), 'key1'.toNSString())
..setObject_forKey_('value2'.toNSString(), 'key2'.toNSString())
..setObject_forKey_('value3'.toNSString(), 'key3'.toNSString());
..setObject('value1'.toNSString(), forKey: 'key1'.toNSString())
..setObject('value2'.toNSString(), forKey: 'key2'.toNSString())
..setObject('value3'.toNSString(), forKey: 'key3'.toNSString());
expect(stringNSDictionaryToMap(d),
{'key1': 'value1', 'key2': 'value2', 'key3': 'value3'});
});

test('non-string value', () {
final d = objc.NSMutableDictionary()
..setObject_forKey_(
objc.NSNumberCreation.numberWithInteger_(5), 'key'.toNSString());
..setObject(objc.NSNumberCreation.numberWithInteger(5),
forKey: 'key'.toNSString());
expect(() => stringNSDictionaryToMap(d), throwsUnsupportedError);
});

test('non-string key', () {
final d = objc.NSMutableDictionary()
..setObject_forKey_(
'value'.toNSString(), objc.NSNumberCreation.numberWithInteger_(5));
..setObject('value'.toNSString(),
forKey: objc.NSNumberCreation.numberWithInteger(5));
expect(() => stringNSDictionaryToMap(d), throwsUnsupportedError);
});
});
Expand All @@ -57,16 +57,16 @@ void main() {
test('single string input', () {
final array = stringIterableToNSArray(['apple']);
expect(array.count, 1);
expect(objc.NSString.castFrom(array.objectAtIndex_(0)).toDartString(),
expect(objc.NSString.castFrom(array.objectAtIndex(0)).toDartString(),
'apple');
});

test('multiple string input', () {
final array = stringIterableToNSArray(['apple', 'banana']);
expect(array.count, 2);
expect(objc.NSString.castFrom(array.objectAtIndex_(0)).toDartString(),
expect(objc.NSString.castFrom(array.objectAtIndex(0)).toDartString(),
'apple');
expect(objc.NSString.castFrom(array.objectAtIndex_(1)).toDartString(),
expect(objc.NSString.castFrom(array.objectAtIndex(1)).toDartString(),
'banana');
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ void main() {
expect(
ConnectionException(
'failed to connect',
NSError.errorWithDomain_code_userInfo_(
'NSURLErrorDomain'.toNSString(), -999, null))
NSError.errorWithDomain('NSURLErrorDomain'.toNSString(),
code: -999, userInfo: null))
.toString(),
'CupertinoErrorWebSocketException: failed to connect '
'[The operation couldn’t be completed. '
Expand Down
2 changes: 1 addition & 1 deletion pkgs/cupertino_http/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dev_dependencies:
http_profile: ^0.1.0
integration_test:
sdk: flutter
objective_c: ^7.0.0
objective_c: ^8.0.0
test: ^1.21.1
web_socket_conformance_tests:
path: ../../web_socket_conformance_tests/
Expand Down
4 changes: 2 additions & 2 deletions pkgs/cupertino_http/lib/src/cupertino_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class URLSessionConfiguration
}
final d = objc.NSMutableDictionary.alloc().init();
headers.forEach((key, value) {
d.setObject_forKey_(value.toNSString(), key.toNSString());
d.setObject(value.toNSString(), forKey: key.toNSString());
});
_nsObject.HTTPAdditionalHeaders = d;
}
Expand Down Expand Up @@ -746,7 +746,7 @@ class MutableURLRequest extends URLRequest {
///
/// See [NSMutableURLRequest.requestWithURL:](https://developer.apple.com/documentation/foundation/nsmutableurlrequest/1414617-allhttpheaderfields)
factory MutableURLRequest.fromUrl(Uri uri) {
final url = objc.NSURL.URLWithString_(uri.toString().toNSString())!;
final url = objc.NSURL.URLWithString(uri.toString().toNSString())!;
return MutableURLRequest._(ncb.NSMutableURLRequest.requestWithURL_(url));
}

Expand Down
Loading