Skip to content

Instantly share code, notes, and snippets.

View wptechprodigy's full-sized avatar
🏠
Working from home

Waheed Afolabi wptechprodigy

🏠
Working from home
View GitHub Profile
@wptechprodigy
wptechprodigy / sendPOSTRequestWithUR.m
Last active December 17, 2023 22:58
POST request to a URL using Objective-C
- (void)sendPOSTRequestWithURL:(NSURL *)url parameters:(NSDictionary *)parameters completionHandler:(void (^)(NSData *, NSURLResponse *, NSError *))completionHandler {
// Create a mutable URL request
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
// Set the request method to POST
[request setHTTPMethod:@"POST"];
// Set the request body with the parameters
NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
[request setHTTPBody:postData];