Hi Sir, In this video, View Controller is tightly coupled to viewModel. So basically view controller is depending on viewModel. How can me make it loosely coupled ?
Hey, please check my mvvm video on product api there i use protocol so basically you are not depending on viewmodel. We depend on abstract layer protocol. This video is mainly based on Async Await 😄 Thank You
understanding achi ha but Yogesh hamara do cash ab har Controller me linkhana pary ga so i think achi aproach ni ha ViewController level pay it should be in wrapper please reply.
Question: When I run the request function in which thread does it run ? Does it run on main thread or uses a qos like .utility. Because when the we get response from data and setting it directly it is giving the error that it needs to be done in the main thread. So just wanted to know which thread it is used by default by the async functions. And also in non async function what is the thread. So like if i didnt had the async function and then I was setting the data in the fetchUsers I think it wont give me any issue as per my experience. PS: Nice videos. Wanted to learn concurrency. Very informative.
In this video we create url and we pass in datatask method. If you want to pass header, type etc first you need to create a urlrequest and then pass it to dataTask(for: urlRequest) ok sagar 🤝 In request you can add method type, body and header.
Very detailed explanation...!! Thanks for sharing...
Super Awesome Explaination Yogesh Sir.. 👌🙌👏
Thank you so much 🙂
Super 👍
Thankyou Yogesh bhai awesome hai ye..
Very nicely explained. Thankyou :)
Super...and Thanksssss....
Thank you so much Yogesh sir I really want to understand the concept of async await. Thanks again
You're most welcome brother :-)
Super❤❤
Thanks 🔥
Thank you such video Yogesh sir :)
Most welcome 😊
Thanks bro, I appreciate your way of explaining and the knowledge you share.
Glad you like it. Please like, subscriber and share with you friends :)
that is also good one,Thanks
Glad you like it!
❤❤
જય દ્વારીકાધીશ યોગેશ ભાઈ
જય દ્વારીકાધીશ ભાઈ
Nice explanation. Please start swiftui tutorials.
❤
Good explanation!
keep it up 🎉
Thank you! 😃
Hello Yosgesh, can you please make a video on more than 2 API calls on any screen using
async/await
Bro could you please create a video about advanced debugging techniques.
Hi Sir,
In this video, View Controller is tightly coupled to viewModel. So basically view controller is depending on viewModel. How can me make it loosely coupled ?
Hey, please check my mvvm video on product api there i use protocol so basically you are not depending on viewmodel. We depend on abstract layer protocol. This video is mainly based on Async Await 😄 Thank You
Try to save api response in core data and realme db or firebase db .
understanding achi ha but Yogesh hamara do cash ab har Controller me linkhana pary ga so i think achi aproach ni ha ViewController level pay it should be in wrapper please reply.
Hello yogesh..do you give online classes to learn iOS development?i want to learn please reply
Sir..Can we have a session on video call , video streaming etc?
Could you make a video GraphQL ?
Hi Sir,
Does @MainActor blocks main thread ?
Hey, No it is not block the main thread. It call your ui or logic in main thread 👍🏻
How can we send the multiple json object in single post request?
Question: When I run the request function in which thread does it run ? Does it run on main thread or uses a qos like .utility. Because when the we get response from data and setting it directly it is giving the error that it needs to be done in the main thread. So just wanted to know which thread it is used by default by the async functions. And also in non async function what is the thread. So like if i didnt had the async function and then I was setting the data in the fetchUsers I think it wont give me any issue as per my experience.
PS: Nice videos. Wanted to learn concurrency. Very informative.
How we can pass params,headers and api type(get,post) using this method ?
In this video we create url and we pass in datatask method. If you want to pass header, type etc first you need to create a urlrequest and then pass it to dataTask(for: urlRequest) ok sagar 🤝
In request you can add method type, body and header.
multiply images wala bhee
kr daaa
Hello Yogesh
Thank you for all content.
When we can see RXSwift with MVVM videos ?? Please plan this as well if possible, thank you
Will upload soon bro 🤝
RX Swift is totally rubish
import Foundation
import KRProgressHUD
import SwiftyJSON
import Alamofire
class ApiCall: NSObject, RequestInterceptor {
static let share: ApiCall = {
return ApiCall()
}()
let retryLimit = 3
func request(_ apiRouter: URLRequestConvertible, hasProgress: Bool, isShowError: Bool = true, completion: @escaping (JsonResult) -> Void) {
if !NetworkServices.isNetworkAvailable() {
if isShowError {
Toast(text: "Unable to connect to the server, please check your network connection and try again").show()
}
completion(.failure(.serverTrustEvaluationFailed(reason: .noCertificatesFound), nil))
return
}
if hasProgress {
KRProgressHUD.show()
}
AF.request(apiRouter, interceptor: self).validate().responseData { response in
if hasProgress {
KRProgressHUD.dismiss()
}
switch response.result {
case .success(let data):
do {
let json = try JSON(data: data)
print("- result \(apiRouter.urlRequest?.url?.absoluteString ?? ""): \(json)")
completion(.success(json))
} catch {
completion(.success(JSON.null))
}
case .failure(let error):
print(error.localizedDescription)
completion(.failure(error, response.response?.statusCode))
break
}
}
}
func requestFormData(_ router: URLRequestConvertible, image: ImageModel?, hasProgress: Bool, completion: @escaping (JsonResult) -> Void) {
if !NetworkServices.isNetworkAvailable() {
Toast(text: "Unable to connect to the server, please check your network connection and try again").show()
completion(.failure(.serverTrustEvaluationFailed(reason: .noCertificatesFound), nil))
return
}
if hasProgress {
KRProgressHUD.show()
}
var params: [String: Any]?
var url: String?
var headers: HTTPHeaders?
var method: HTTPMethod?
if let rt = router as? APIRouter {
params = rt.parameters
url = Api.me.baseUrl + rt.path
headers = rt.headers
method = rt.method
}
guard let pr = params, let u = url, var h = headers, let m = method else {
return
}
h["Content-type"] = "multipart/form-data"
h["Accept"] = "*/*"
print("requestFormData")
print("url: \(u)")
print("params: \(pr)")
print("method: \(m)")
print("headers: \(h)")
let block = { (multipart: MultipartFormData) in
URLEncoding.default.queryParameters(pr).forEach { (key, value) in
if let data = value.data(using: .utf8) {
multipart.append(data, withName: key)
}
}
if let image = image, let im = ImagePickerManager.loadImage(fileName: image.id), let data = im.resizeImageToData(CGSize(width: 1024, height: 1024)) {
multipart.append(data, withName: "image", fileName: "\(Date.init().timeIntervalSince1970).png", mimeType: "image/png")
}
}
AF.upload(multipartFormData: block, to: u, method: m, headers: h)
.responseData { response in
if hasProgress {
KRProgressHUD.dismiss()
}
switch response.result {
case .success(let data):
do {
let json = try JSON(data: data)
print("- result: \(json)")
completion(.success(json))
} catch {
completion(.success(JSON.null))
}
case .failure(let error):
print(error.localizedDescription)
completion(.failure(error, response.response?.statusCode))
break
}
}
}
}
extension URLEncoding {
public func queryParameters(_ parameters: [String: Any]) -> [(String, String)] {
var components: [(String, String)] = []
for key in parameters.keys.sorted(by:
Very detailed explanation...!! Thanks for sharing...
Glad it was helpful!
❤❤