Open ghost opened 7 years ago
How is your storyboard?
i didn't get you! i am new to swift can u explain briefly
Just show a screenshot of your Main.storyboard.
Sorry can you upload the main.storyborad (you have to compress it in a zip) itself because this is too small in the screenshot.
You have to push the SWRController not the agentVC
kk Thank you So much sir
Main.storyboard.zip if i am pushing i am not getting menu option
if i am presenting I am able to see menu button options
please help me sir
Try to embed the controller in a navigation controller.
And you don't have a sw_front segue. It should be HomeVC, no?
Thank You so much !!!!!!!It working Now.
hi sir could you please help me in writing generic handler class URL Request. Thanks in advance.
Can you elaborate? What kind of request? Did you start writing something?
I need to write a ServerRequestHandler which would be generic and which i could reuse in every other ViewControllers of my application. right now am replicating the same set of logic in every set of ViewControllers which is not object oriented.Can you please help me to write that Generic class. BTW i am using URLRequest and URLSession to do so.
func purchaseRequest() {
let urlString = String(format:"http://mandi.connect2community.in/c4t/ledger?queryId=QUERY_DAY_BOOK&args=community_id:7f6a033f-6ae8-4e27-bb58-66238fc3be84,last_update_time:0,account_id:7f6a033f-6ae8-4e27-bb58-66238fc3be84^2017-2018^1,type:SALES,records:20")
let encodedurl = urlString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
let url = URL(string:encodedurl!)
var request = URLRequest(url: url! as URL)
let result = UserDefaults.standard.value(forKey:"session_id")
let ss : String = result as! String
request.httpMethod = "GET"
request.addValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
request.addValue(("session_id="+ss), forHTTPHeaderField: "Cookie")
request.timeoutInterval = 3
let task = URLSession.shared.dataTask(with: request as URLRequest!, completionHandler: { (data, response, error) in
if error != nil{
print(error?.localizedDescription as Any)
return
}
do {
let json = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as? NSDictionary
print(json ?? "empty from server ")
if let parseJSON = json {
print(parseJSON)
let success = Int(json?["errCode"]! as! Double)
if let resultArray = parseJSON["resource"] as?[[String:AnyObject]]{
for (index,_) in resultArray.enumerated()
{
if let vocherno = resultArray[index]["voucher_no"]as? String {
print(vocherno)
if let eventDate = resultArray[index]["event_date"]as? Int {
let event_date = Constants.getDateStringforMessageVC(dateConveriosn:Double(eventDate))
print(event_date)
if let particular = resultArray[index]["particular"]as? String {
print(particular)
if let accountName = resultArray[index]["account_name"]as? String {
print(accountName)
if let amount = resultArray[index]["dr_amount"]as? Int {
self.purchaseresult.append(Purchase(vocher: vocherno, eventdate: event_date, particular: particular, accountname: accountName, amount: amount))
print(amount)
}}}}}}
}
if (success != 0) {
return
}
else{
DispatchQueue.main.async {
self.daybooktableview.reloadData()
}
}}
}
catch let error as NSError {
print(error)
}
})
task.resume()
}
Ok, can you give me an URL that will work in a browser? And return a JSON.
These are two demo api's . Please use the first login to get a session id and use that session id in the get request of the second type. Please do open them up in postman rest api client - chrome extension.
FYI, i attach the screenshots of the postman .
And pass this in body of the login api request . as resource as eydlbWFpbF9pZCc6JzkwNjY2NjkzOTMnLCdwYXNzd29yZCc6J21hbmRpJ30=
Nothing in the file Demo.postman_collection.zip
You need to open with the Postman application. which is a chrome extension or an app
or https://www.getpostman.com/
import that file in postman
FYI, please check the screenshot attached.
Ok got it, I had already Postman but I used it only one or two times. Then there are two JSON structure? One for GET and one for POST request?
Yes exactly. One is for login as u cannot get the request unless and until session is validated. So please do use that POST request - login api for logging in . by which you get the session_id . use this session_id value in the next GET request and get the json object. otherwise you would get an error. @iDevelopper FYI, please check the screenshots .
I wrote a sample to show how you could have a generic API Manager in your application (open the xcworkspace, because it use the SwiftyJSON pod):
Now we have to add a parameter to the func data_request:
func data_request(_ params: String, onSuccess: @escaping(JSON) -> Void, onFailure: @escaping(Error) -> Void)
var urlString = baseURL + params
urlString = urlString.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!
...
Or add functions for different request types.
And create the different models to return these models instead a json.
What are the models you can receive?
hi @iDevelopper Can you show me how do we pass values and populating Values Into tableview as per the design standards following Design patterns from get request. Maybe i can reuse a single model as per the server architecture as all i do recieve are just string, int, double or boolean values.
FYI, these are the API's @iDevelopper
So you have two types of request, ledger and community? Then we have to create two object class.
Could we continue this discussion via mail as we are in an SWRevealViewController issue and it is not the right place for this! (patrick.bodet4@wanadoo.fr)?
When you will send me a email, I'll send you a sample!
Hi Patrick,
can you show me one ViewController populating with
Generic URL Request Handler so that i will follow the remaining ViewControllers. Please i am new to swift thats why i am asking these many no of times please Patrick. Please Guide me as a Teacher Please
On Wed, Sep 6, 2017 at 11:20 AM, prasad sanaboina < sanaboinaprasadofficial@gmail.com> wrote:
Respected sir, I already sent the whole project. Can you please check that revert back if u need anything other than that i can send you.
FYI, i reattached the same zip file of the project.
On Tue, Sep 5, 2017 at 2:05 PM, Patrick notifications@github.com wrote:
When you will send me a email, I'll send you a sample!
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/John-Lluch/SWRevealViewController/issues/728#issuecomment-327109233, or mute the thread https://github.com/notifications/unsubscribe-auth/AdDSjGmIiymZ-7-bmDZKEJMzXW8k8A_Eks5sfQe2gaJpZM4PIR6u .
Yes I just want to continue elsewhere than here, because we are in a SWRevealViewController issue. Can I send you a sample at sanaboinaprasadofficial@gmail.com ?
Yes please do . anything is fine . I need the SWRevealController in the third screen . So i think that wouldn't be an issue. But i need to follow the MVC pattern w.r.t it .
On Thu, Sep 7, 2017 at 5:25 PM, Patrick notifications@github.com wrote:
Yes I just want to continue elsewhere than here, because we are in a SWRevealViewController issue. Can I send you a sample at sanaboinaprasadofficial@gmail.com ?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/John-Lluch/SWRevealViewController/issues/728#issuecomment-327777547, or mute the thread https://github.com/notifications/unsubscribe-auth/AdDSjIiNEPHAUeLwE-vFas8DSdYsVzcDks5sf9m0gaJpZM4PIR6u .
I sent you a sample yesterday. APIManagerSample. Did you receive it?
Oh yeah, I recieved . Sorry i missed out that email. Thank you.
On Fri, Sep 8, 2017 at 6:20 PM, Patrick notifications@github.com wrote:
I sent you a sample yesterday. APIManagerSample. Did you receive it?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/John-Lluch/SWRevealViewController/issues/728#issuecomment-328094353, or mute the thread https://github.com/notifications/unsubscribe-auth/AdDSjAYRt0oM0ml_3mXSjCyURa-oTY9Fks5sgTf5gaJpZM4PIR6u .
Hi Patrick,
Thanks for the help till now. I am very new to iOS Swift. I want to code like Professionals with respective code optimisation. Can you help me in that.
On Fri, Sep 8, 2017 at 7:30 PM, prasad sanaboina < sanaboinaprasadofficial@gmail.com> wrote:
Oh yeah, I recieved . Sorry i missed out that email. Thank you.
On Fri, Sep 8, 2017 at 6:20 PM, Patrick notifications@github.com wrote:
I sent you a sample yesterday. APIManagerSample. Did you receive it?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/John-Lluch/SWRevealViewController/issues/728#issuecomment-328094353, or mute the thread https://github.com/notifications/unsubscribe-auth/AdDSjAYRt0oM0ml_3mXSjCyURa-oTY9Fks5sgTf5gaJpZM4PIR6u .
actually i need to push ViewController On swrevealViewControlller . When i am trying to do so It is giving parent as nil. if i am presenting it is working fine. i am new to swift Please help me . presentingVC
let storyboard = UIStoryboard(name: "Main", bundle: nil) let SWRController = storyboard.instantiateViewController(withIdentifier:"SWRevealViewController") switch (userType.loader) {
case .Agent: let destination = storyboard.instantiateViewController(withIdentifier: "Agent") (SWRController as? SWRevealViewController)?.frontViewController = destination self.present(SWRController, animated: true, completion:nil) break pushing VC
let destination = storyboard.instantiateViewController(withIdentifier: "Agent") as!UINavigationController let agentVC = destination.topViewController as! AgentVC (SWRController as? SWRevealViewController)?.frontViewController = agentVC self.navigationController?.pushViewController(agentVC, animated: true)
it gives parent nil please helpme