Fix nullability warnings/errors
Summary: ^ Reviewed By: passy Differential Revision: D50640020 fbshipit-source-id: d42b938520203a6ce232717c1adc43da176457e3
This commit is contained in:
committed by
Facebook GitHub Bot
parent
da7917cefe
commit
7f6d1cf55b
@@ -19,25 +19,32 @@
|
||||
}
|
||||
|
||||
- (IBAction)tappedGithubLitho:(UIButton*)sender {
|
||||
[[[NSURLSession sharedSession]
|
||||
dataTaskWithURL:
|
||||
[NSURL
|
||||
URLWithString:
|
||||
@"https://raw.githubusercontent.com/facebook/litho/main/docs/static/logo.png"]
|
||||
completionHandler:^(
|
||||
NSData* _Nullable data,
|
||||
NSURLResponse* _Nullable response,
|
||||
NSError* _Nullable error) {
|
||||
if (error && !data) {
|
||||
return;
|
||||
}
|
||||
NSLog(@"Got Image");
|
||||
}] resume];
|
||||
NSURL* url = [NSURL
|
||||
URLWithString:
|
||||
@"https://raw.githubusercontent.com/facebook/litho/main/docs/static/logo.png"];
|
||||
if (!url) {
|
||||
return;
|
||||
}
|
||||
|
||||
[[[NSURLSession sharedSession] dataTaskWithURL:url
|
||||
completionHandler:^(
|
||||
NSData* _Nullable data,
|
||||
NSURLResponse* _Nullable response,
|
||||
NSError* _Nullable error) {
|
||||
if (error && !data) {
|
||||
return;
|
||||
}
|
||||
NSLog(@"Got Image");
|
||||
}] resume];
|
||||
}
|
||||
|
||||
- (IBAction)tappedPOSTAPI:(UIButton*)sender {
|
||||
NSString* post = @"https://demo9512366.mockable.io/FlipperPost";
|
||||
NSURL* url = [NSURL URLWithString:post];
|
||||
NSURL* url =
|
||||
[NSURL URLWithString:@"https://demo9512366.mockable.io/FlipperPost"];
|
||||
if (!url) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSMutableURLRequest* urlRequest = [NSMutableURLRequest requestWithURL:url];
|
||||
[urlRequest addValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
|
||||
[urlRequest addValue:@"application/json" forHTTPHeaderField:@"Accept"];
|
||||
@@ -57,42 +64,56 @@
|
||||
[[[NSURLSession sharedSession]
|
||||
dataTaskWithRequest:urlRequest
|
||||
completionHandler:^(
|
||||
NSData* _Nullable data,
|
||||
NSData* data,
|
||||
NSURLResponse* _Nullable response,
|
||||
NSError* _Nullable dataTaskError) {
|
||||
if (dataTaskError || !data) {
|
||||
if (dataTaskError) {
|
||||
[weakSelf
|
||||
showAlertWithMessage:@"Received error in POST API response"];
|
||||
return;
|
||||
}
|
||||
NSDictionary* dict =
|
||||
[NSJSONSerialization JSONObjectWithData:data
|
||||
options:0
|
||||
error:&dataTaskError];
|
||||
NSLog(@"MSG-POST: %@", dict[@"msg"]);
|
||||
if (data == nil) {
|
||||
[weakSelf
|
||||
showAlertWithMessage:@"No data received in POST API response"];
|
||||
} else {
|
||||
NSDictionary* dict =
|
||||
[NSJSONSerialization JSONObjectWithData:data
|
||||
options:0
|
||||
error:&dataTaskError];
|
||||
NSLog(@"MSG-POST: %@", dict[@"msg"]);
|
||||
|
||||
[weakSelf showAlertWithMessage:@"Received response from POST API"];
|
||||
[weakSelf showAlertWithMessage:@"Received response from POST API"];
|
||||
}
|
||||
}] resume];
|
||||
}
|
||||
|
||||
- (IBAction)tappedGetAPI:(UIButton*)sender {
|
||||
NSURL* url =
|
||||
[NSURL URLWithString:@"https://demo9512366.mockable.io/FlipperGet"];
|
||||
if (!url) {
|
||||
return;
|
||||
}
|
||||
__weak NetworkViewController* weakSelf = self;
|
||||
[[[NSURLSession sharedSession]
|
||||
dataTaskWithURL:
|
||||
[NSURL URLWithString:@"https://demo9512366.mockable.io/FlipperGet"]
|
||||
dataTaskWithURL:url
|
||||
completionHandler:^(
|
||||
NSData* _Nullable data,
|
||||
NSData* data,
|
||||
NSURLResponse* _Nullable response,
|
||||
NSError* _Nullable error) {
|
||||
if (error || !data) {
|
||||
if (error) {
|
||||
[weakSelf showAlertWithMessage:@"Received error in GET API response"];
|
||||
return;
|
||||
}
|
||||
NSDictionary* dict = [NSJSONSerialization JSONObjectWithData:data
|
||||
options:0
|
||||
error:&error];
|
||||
NSLog(@"MSG-GET: %@", dict[@"msg"]);
|
||||
[weakSelf showAlertWithMessage:@"Received response from GET API"];
|
||||
if (data == nil) {
|
||||
[weakSelf
|
||||
showAlertWithMessage:@"No data received in GET API response"];
|
||||
} else {
|
||||
NSDictionary* dict = [NSJSONSerialization JSONObjectWithData:data
|
||||
options:0
|
||||
error:&error];
|
||||
NSLog(@"MSG-GET: %@", dict[@"msg"]);
|
||||
[weakSelf showAlertWithMessage:@"Received response from GET API"];
|
||||
}
|
||||
}] resume];
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,11 @@
|
||||
}
|
||||
|
||||
- (IBAction)tappedSave:(id)sender {
|
||||
[self.userDefaults setObject:self.valueTextField.text
|
||||
forKey:self.keyTextField.text];
|
||||
NSString* key = self.keyTextField.text;
|
||||
NSString* value = self.valueTextField.text;
|
||||
if (key != nil) {
|
||||
[self.userDefaults setObject:value forKey:key];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user