Skip to content

Cast error.code to long to avoid using NSInteger as %ld format warnings. #1291

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

Merged
merged 2 commits into from
Oct 22, 2019
Merged
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
4 changes: 4 additions & 0 deletions packages/cloud_firestore/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.12.9+6

* Cast error.code to long to avoid using NSInteger as %ld format warnings.

## 0.12.9+5

* Fixes a crash on Android when running a transaction without an internet connection.
Expand Down
4 changes: 2 additions & 2 deletions packages/cloud_firestore/ios/Classes/CloudFirestorePlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
static FlutterError *getFlutterError(NSError *error) {
if (error == nil) return nil;

return [FlutterError errorWithCode:[NSString stringWithFormat:@"Error %ld", error.code]
return [FlutterError errorWithCode:[NSString stringWithFormat:@"Error %ld", (long)error.code]

Choose a reason for hiding this comment

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

LGTM!
Another way instead of force casting would be always use NSObjects
such as

Suggested change
return [FlutterError errorWithCode:[NSString stringWithFormat:@"Error %ld", (long)error.code]
return [FlutterError errorWithCode:[NSString stringWithFormat:@"Error %@", @(error.code)]

But I'm ok with whichever you prefer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Good to know!

message:error.domain
details:error.localizedDescription];
}
Expand Down Expand Up @@ -423,7 +423,7 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
}
completion:^(id transactionResult, NSError *error) {
if (error != nil) {
result([FlutterError errorWithCode:[NSString stringWithFormat:@"%ld", error.code]
result([FlutterError errorWithCode:[NSString stringWithFormat:@"%ld", (long)error.code]
message:error.localizedDescription
details:nil]);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cloud_firestore/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for Cloud Firestore, a cloud-hosted, noSQL database
live synchronization and offline support on Android and iOS.
author: Flutter Team <[email protected]>
homepage: https://github.com/FirebaseExtended/flutterfire/tree/master/packages/cloud_firestore
version: 0.12.9+5
version: 0.12.9+6

flutter:
plugin:
Expand Down